当前位置:编程学习 > C#/ASP.NET >>

高手指引一下:System.NullReferenceException: 未将对象引用设置到对象的实例。

SqlCommand commnd = new SqlCommand("insert into 进货单(供货商,品名,单价,数量,金额,仓库,进货日期,业务员)  values('" + DropDownList1.SelectedItem.Text + "','" + DropDownList2.SelectedItem.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + DropDownList3.SelectedItem.Text + "','" + TextBox1.Text + "','" + TextBox5.Text + "')", connections);
        connections.Open();
        commnd.ExecuteNonQuery();
        connections.Close(); --------------------编程问答-------------------- connections 这个东东是哪里来的
代码里有这个吗

string conn = "server=.;database=你的数据库;uid=用户名(一般是用sa);pwd=密码"; //这个有很多种写法
SqlConnection connections = new SqlConnection(conn)  //有这句话没
--------------------编程问答--------------------
string conn = "server=.;database=你的数据库;uid=用户名(一般是用sa);pwd=密码"; //链接字符串   这个有很多种写法
SqlConnection connections = new SqlConnection(conn) //有这句话没 
--------------------编程问答-------------------- 有
--------------------编程问答-------------------- 应该是第一行或者第二行有问题
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,