jaylisto Posted February 2, 2015 Share Posted February 2, 2015 (edited) this is a very simple task, it insert name, address and age to the database error when the sql data base from server is use. but when data base from folder app_data is used its working. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; namespace WebApplication5 { public partial class WebForm1 : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); protected void Page_Load(object sender, EventArgs e) { con.Open(); } protected void Button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("insert into listotable values('"+TextBox1.Text+"','" +TextBox2.Text+"', '"+TextBox3.Text+"')",con); cmd.ExecuteNonQuery(); con.Close(); TextBox3.Text=""; TextBox2.Text=""; TextBox1.Text=""; } } } Edited February 2, 2015 by jaylisto Link to comment Share on other sites More sharing options...
justsomeguy Posted February 2, 2015 Share Posted February 2, 2015 The error message says that you're trying to use something that isn't an object. The highlighted line includes a few objects, so make sure that all of them are set to what you need them to be. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now