From within a C# WinForms app I must execute a parameterized Stored Procedure on a MS SQL Express Server. The Database Connection works, the Procedure works either, but I ge
Anyway it's better your code would look like this:
using (OdbcConnection connection = new OdbcConnection(connectionString) )
using (OdbcCommand command = connection.CreateCommand())
{
command.CommandText = commandText;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@KundenEmail", OdbcType.NChar, 50).Value = KundenEmail
DataTable dataTable = new DataTable();
connection.Open();
using (OdbcDataAdapter adapter = new OdbcDataAdapter(command))
{
adapter.Fill(dataTable);
}
}
But rather better to use SqlConnection/SqlCommand/SqlDataAdapter instead of ODBC types. Syntax will be still the same.