Autor Beitrag
erfahrener Neuling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: Mi 27.04.16 14:31 
Hallo,

ich will eine in der Datenbank gespeicherte Prozedur über ein C# Programm ausführen, weiß aber nicht, wie ich Parameter einem Command hinzufüge. Es handelt sich dabei um eine Firebird-Datenbank, aber die Synthax ist ja ziemlich ähnlich.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
using (FbConnection connection = new FbConnection(this.ConnectionString))
{
    string parameter = "123456789";   //mein Parameter (mehr braucht die Prozedur nicht)

    connection.Open();

    using (FbCommand command = connection.CreateCommand())
    {
        command.CommandType = System.Data.CommandType.StoredProcedure;
        command.CommandText = "MeineProzedur";
                      //wie gebe ich das an?

        using (FbDataReader reader = command.ExecuteReader())
        {
            reader.Read();
        }
    }
}
Ein einfaches Beipiel würde mir schon reichen.
Tipps und Erklärung würden mir weiterhelfen. Danke dafür!
erfahrener Neuling Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: Mi 27.04.16 15:38 
Ok hab's rausgefunden:
ausblenden C#-Quelltext
1:
command.Parameters.AddWithValue(ParamName, ParamValue);