Before that line just put cmd.Connection = con;
> Date: Sun, 14 Feb 2010 08:00:35 -0800 > Subject: [DotNetDevelopment] Asp.NET Connectivity > From: [email protected] > To: [email protected] > > Hi All, > For more than two days I m trying this problem. Some one > please help me out. My scenario is I want to directly insert data into > my table from the input which I get it from text boxes. Here is my > code... > > con = new SqlConnection(); > con.ConnectionString = "Data Source=santhosh;Initial > Catalog=ecop;User ID=sa;Password=test"; > con.Open(); > SqlCommand cmd = new SqlCommand(); > cmd.CommandText="INSERT INTO > com(st_id,name,addres,phone,ct_type,brief_incident,suspect,date,time) > VALUES(@st_id,@name,@addres,@phone,@ct_type,@brief_incident,@suspect,@date,@time)"; > cmd.Parameters.Add(new > SqlParameter("@st_id",DropDownList1.SelectedValue)); > cmd.Parameters.Add(new SqlParameter("@name",TextBox1.Text)); > cmd.Parameters.Add(new SqlParameter("@addres",TextBox2.Text)); > cmd.Parameters.Add(new SqlParameter("@phone",TextBox3.Text)); > cmd.Parameters.Add(new > SqlParameter("@ct_type",DropDownList2.SelectedItem)); > cmd.Parameters.Add(new > SqlParameter("@brief_incident",TextBox6.Text)); > cmd.Parameters.Add(new > SqlParameter("@suspect",TextBox4.Text)); > cmd.Parameters.Add(new SqlParameter("@date",TextBox5.Text)); > cmd.Parameters.Add(new SqlParameter("@time",TextBox7.Text)); > SqlDataReader dr = cmd.ExecuteReader();------> In this > particular line I m getting Connection property has not been > initialized. > > some one help me out to get ride of this problem... > > With Regards, > Santhosh V Kumar _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/201469227/direct/01/
