2017-04-19 102 views
-1

using System;使用System.Collections.Generic;使用System.Linq;使用System.Web;使用System.Web.UI;使用System.Web.UI.WebControls;使用System.Data.SqlClient;使用System.Configuration;使用System.Data; public partial class working:System.Web.UI.Page {protected void Page_Load(object sender,EventArgs e){} protected void Button1_Click(object sender,EventArgs e){SqlConnection con = new SqlConnection(“Data Source = DEVELOPER; Initial Catalog = working; Integrated Security = True“); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText =“insert into sample(name,mobile_number,email_id,gender)values('”+ TextBox1.Text +“','”+ TextBox2.Text +“','”+ TextBox3.Text +“','”+ TextBox4的.text + “')”; cmd.ExecuteNonQuery(); con.Close();的Response.Write( “提交”); }}它给了我这个错误:-executenonquery连接属性尚未初始化

回答

0

你必须提供连接字符串这样 “”“数据源= DEVELOPER;初始目录=工作;集成安全性=真”“”“

‘’” 数据源=桌面 - SIJVIOU \ SQLSERVERPOONIA;初始目录= YourDBName;集成安全性= True“providerName = System.Data.SqlClient”“”

相关问题