Hi everyone,
I have a web application in C#. When i run the appl i get this error "
Procedure or function xqxqxq has too many arguments specified", and I am passing just one parameter.. the only one the stored procedure needs. Pls help, I am stuck. Thank you.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Procedure or function has too many arguments specified.
Source Error:
Line 26: { Line 27: sqlSelectCommand1.Parameters.Add("@xqxqxqID", 219760); Line 28: sqlDataAdapter1.Fill(my1); Line 29: DataGrid1.DataBind(); Line 30: // Put user code to initialize the page here |
Source File: c:\inetpub\wwwroot\test_09_19\webform3.aspx.cs Line: 28
Stack Trace:
[SqlException: Procedure or function lucian has too many arguments specified.] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) _09_19.WebForm3.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\_09_19\webform3.aspx.cs:28 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain() |
Procedure or function has too many arguments specified
clrudolphi
Crystal1
try {
int xqxqID = int.Parse(txt.Text); // I prefer int.Parse rather than Convert.*
sqlConnection1.Open();
sqlSelectCommand1.Parameters["@xqxqID"] = 219760896;
sqlDataAdapter1.Fill(myDataSet21);
DataGrid2.DataBind();
} finally {
if (sqlConnection1 != null) {
sqlConnection1.Close();
}
}
Learning
Showing us an exception without code makes it near impossible to figure out what is wrong.
bram
try
{
int xqxqID;xqxqID = Convert.ToInt32(txt.Text);
sqlConnection1.Open();sqlSelectCommand1.Parameters.Add("@xqxqID", 219760896);
sqlDataAdapter1.Fill(myDataSet21);
DataGrid2.DataBind();
}
finally{
if (sqlConnection1 != null){
sqlConnection1.Close();
}
}Once again Thank you... i tried with DataReader and it works.. any ideeas how can fill a data set with DataReader.
SqlConnection conn =
null;SqlDataReader rdr =
null; int xqxqID= 219760;try
{
conn =
newSqlConnection("Server=(local);DataBase=xqxq2;Integrated Security=SSPI");
conn.Open();
SqlCommand cmd = new SqlCommand("xqxq", conn); cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.Add(
new SqlParameter("@xqxqID", xqxqID));rdr = cmd.ExecuteReader(); while (rdr.Read())
{
Response.Write(rdr["xqxq_id"]);
}
}
finally{
if (conn != null){
conn.Close();
}
if (rdr != null){
rdr.Close();
}
}
}