today i fot one error. i am not able to understand why it is. i hope somebody will help me here
my method is
public UserFamilyInfoBO GetUserFamilyInfo(Int64 UserId)
{
try
{
DataSet Ds = new DataSet();
SqlCommand Cmd = new SqlCommand("GetUserFamilyInfo", Cn);
SqlDataAdapter Da = new SqlDataAdapter();
Da.SelectCommand = Cmd;
Cmd.Parameters.Add("@UserId", SqlDbType.BigInt).Value = UserId;
Cn.Open();
Da.Fill(Ds);
Cn.Close();
return SetBO(Ds.Tables[0]);
}
catch (Exception)
{
return null;
}
}
when Da.Fill(Ds) is executed it throws error "Procedure or function 'GetUserFamilyInfo' expects parameter '@UserId', which was not supplied."
i have already added parameter @UserId. and i am getting its value also when debugging. still i am getting the error.
I don't know whether it's relevant, but you haven't specified the type of the command. If this is a stored procedure, try using:
Cmd.CommandType = CommandType.StoredProcedure;
It's possible that it's ignoring the parameter on the grounds that it doesn't appear anywhere in the text of the command - which doesn't make sense for a SQL query, but does make sense for a stored procedure.
If that doesn't help, you might want to look in the logs on SQL Server to see what it's actually being sent.
也许您需要将cmd.CommandType设置为StoredProcedure
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.