internal DataTable GetConformedResults(string spName, string fName, string lName) { DataTable dt = new DataTable(); SqlConnection con = new SqlConnection("Data Source=BUDDHIKA-PC\\SQLEXPRESS;Initial Catalog=VertualDoctor;Integrated Security=True"); con.Open(); SqlCommand SqlCmd = new SqlCommand(spName, con); SqlCmd.Parameters.Add("@vcFistName", DbType.String).Value = fName; SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.Add("@vcLastName", DbType.String).Value = lName; SqlCmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter DataAdp = new SqlDataAdapter(); DataAdp.SelectCommand = SqlCmd; DataSet result = new DataSet(); //Create a dataset DataAdp.Fill(result, "result"); //Fill the dataset dt = result.Tables["result"]; con.Close(); con.Dispose(); return dt; }
In our project we had many many stored procedures and many parameters passes to those sps. But in only one sp it gives error message something like this; "Incorrect number of arguments for PROCEDURE sproc_t_l_Contract_Select_BySearchCriteria; expected 3, got 2” Work long time on this sp but coudnt find it. So i tried to write it again from the begining. In this time it was work perfectly.This problem occurs because of the space between data type and its length. Ex. pName varchar(50) - working pName varchar (50) - Not working But it does not mention syntax error or something.So this error message make us vulnerable.
Comments