c#与数据库的链接问题
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace zsg
{
public partial class Form1 : Form
{
private SqlConnection dbConnection;
public Form1()
{
InitializeComponent();
}
//连接数据库
private void button1_Click(object sender, EventArgs e)
{
string strConn;
try
{
dbConnection = new SqlConnection();
strConn = "DataSource=localhost;";
strConn += "Initial Catalog=lunwen;";
strConn += "Integrated Security=Ture";
dbConnection.ConnectionString = strConn;
//dbConnection.Open();
label4.Text = "连接成功";
}
catch (Exception e3)
{
MessageBox.Show(e3.Message);
}
}
}
}
问题在哪?谢谢。