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 get an Error Message:
42000: Missing Parameter '@KundenEmail'
although I'm sure I added the parameter correctly. Maybe some of you could have a look - I don't know what to search for any more...
OdbcConnection ODBCConnection = new OdbcConnection();
try
{
ODBCConnection.ConnectionString = ODBCConnectionString;
ODBCConnection.Open();
}
catch (Exception DatabaseConnectionEx)
{
if (ODBCConnection != null)
ODBCConnection.Dispose();
// Error Message
return null;
}
OdbcParameter ODBCParameter = new OdbcParameter("@KundenEmail", OdbcType.NChar, 50);
ODBCParameter.Value = KundenEmail;
OdbcCommand ODBCCommand = new OdbcCommand("getDetailsFromEmail", ODBCConnection);
ODBCCommand.CommandType = CommandType.StoredProcedure;
ODBCCommand.Parameters.Add(ODBCParameter);
DataTable DataTable = new DataTable();
OdbcDataAdapter ODBCDatadapter = new OdbcDataAdapter(ODBCCommand);
ODBCDatadapter.Fill(DataTable);
ODBCDatadapter.Dispose();
ODBCConnection.Close();
ODBCConnection.Dispose();
This is the error message I get:
ERROR [4200][Microsoft][ODBC SQL Server]The Procedure or method
'getDetailsFromEmail' expects the '@KundenEmail'-parameter, which
was not supplied.
Ah, I missed the connection string
private static String ODBCConnectionString = "Driver={SQL Server};Server=TESTSRV\SQLEXPRESS;Database=TestDatabase;";
Any ideas? Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…