代码如下,显示有一行错误。
private void btnSubmit_Click(object sender, System.EventArgs e)
{
SqlConnection objConnection=new SqlConnection(strConnection);
SqlCommand objCommand=new SqlCommand("CustOrdersOrders",objConnection);
objCommand.CommandType=CommandType.StoredProcedure; SqlParameter objParameter=new SqlParameter("@CustomerID",SqlDbType.NChar,5);
objCommand.Parameters.Add(objParameter);
objParameter.Direction=ParameterDirection.Input;
objParameter.Value=lbCustomers.SelectedItem.Value;//此处出现错误。 objConnection.Open(); dgOutput.DataSource=objCommand.ExecuteReader();
dgOutput.DataBind(); objConnection.Close();
}错误显示:未将对象引用设置到对象的实例。
private void btnSubmit_Click(object sender, System.EventArgs e)
{
SqlConnection objConnection=new SqlConnection(strConnection);
SqlCommand objCommand=new SqlCommand("CustOrdersOrders",objConnection);
objCommand.CommandType=CommandType.StoredProcedure; SqlParameter objParameter=new SqlParameter("@CustomerID",SqlDbType.NChar,5);
objCommand.Parameters.Add(objParameter);
objParameter.Direction=ParameterDirection.Input;
objParameter.Value=lbCustomers.SelectedItem.Value;//此处出现错误。 objConnection.Open(); dgOutput.DataSource=objCommand.ExecuteReader();
dgOutput.DataBind(); objConnection.Close();
}错误显示:未将对象引用设置到对象的实例。
解决方案 »
- Object 类型添加扩展方法后如何使用?
- 关于session的问题
- 网页分辨率变大网页变形?有什么好的解决方案,送分谢谢!!
- ASP.NET中使用Javascript Ajax 怎么返回Json
- DataSet中的Table如何被删除,急求救
- ACCESS数据库相对路径怎么写啊(简单)
- Datagrid的打印问题
- ASP页面编程软件的问题,急
- 哪位朋友有《ASP.NET 入门经典——C# 编程篇》这本书的电子版.高分相赠
- 请教关于DataGrid中使用CheckBox的问题!
- 两个程序,一个是ASP程序,另一个是ASP.NET程序,如何在ASP中把参数传递到ASP.NET中来?
- 在asp.net的窗体中如何使用office工具栏
{
objParameter.Value=lbCustomers.SelectedItem.Value;
}