I am new to SQL, so I need some help. I have a simple stored procedure that counts the rows in the select statement and returns the number of rows. I create an ODBC command and add all the information to it. When I call the stored procedure I get the error. Procedure or function 'CountUsers' expects parameter '@cacLogin', which was not supplied. The stored procedure works fine when I run it SMS. I have no Idea what the problem is. Any help will be greatly appreciated.
The stored procedure is:
CREATE PROCEDURE [dbo].[CountUsers]
(@cacLogin VARCHAR(100),
@rowcount INT OUTPUT)
AS
SELECT @rowcount = COUNT(*)
FROM UserInfo
WHERE strCACLogin = @cacLogin
RETURN @rowcount
GO
The SQL statement is:
public void storedprocedure()
{
int i;
OdbcConnection conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["dbConnect3"].ConnectionString);
OdbcCommand dbComm = new OdbcCommand();
dbComm.Connection = conn;
dbComm.CommandType = CommandType.StoredProcedure;
dbComm.CommandText = "CountUsers";
dbComm.Parameters.Add("@cacLogin", OdbcType.VarChar, 100).Value = "MAULDIN.THOMAS.C.12345";
dbComm.Connection.Open();
i = dbComm.ExecuteNonQuery();
}
OdbcConnectionversus aSqlConnection? - Cam Bruce@rowcount. What happens if you switch to SqlConnection, SqlCommand, etc., instead of ODBC? - Crowcoder