Jump to content

Recommended Posts

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="";
}
}
}
Untitled1_zps60a36e80.jpg
Edited by jaylisto
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...