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));
[B] SqlDataReader dr = cmd.ExecuteReader();[/B]------> 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