protected void Page_Load(object sender, EventArgs e)
{
string r = @"server=.;database=romesh;trusted_connecton=true";
SqlConnection con = new SqlConnection(r);
}
protected void btn_insert_Click(object sender, EventArgs e)
{
string i= "insert into sample values('"+txt1.Text+"','"+txt2.Text+"','"+txt3.Text+"')";
con.open();
SqlCommand cmd = con.createcommend();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "i";
cmd.EndExecuteNonQuery();
con.close();
}
}
// I will get the error my code


Chetan RanpariyaRank #1,852 · 801 reputationPosted Mar 6, 2017, 4:59 AM EST
You have incorrectly declared objects of SqlConnection.
Abhilash J ARank #1,243 · 1.4K reputationPosted Mar 6, 2017, 3:08 AM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Mar 6, 2017, 3:18 AM EST
Santosh Reddy68 reputationPosted Mar 6, 2017, 3:20 AM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Mar 6, 2017, 3:22 AM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Mar 6, 2017, 3:25 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Mar 6, 2017, 3:25 AM EST
Gnanavel SekarRank #333 · 7.5K reputationPosted Mar 6, 2017, 3:59 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Mar 6, 2017, 6:50 AM EST
Santosh Reddy68 reputationPosted Mar 6, 2017, 5:58 PM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Mar 6, 2017, 7:07 PM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Mar 6, 2017, 7:29 PM EST