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 WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=USER-20160806SI\\SQLEXPRESS;uid=sa;pwd=sa database=luke";
conn.Open();
DataTable dt = new DataTable("resouce");
dt.Clear();
string sql = "insert into text1 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
SqlCommand command = new SqlCommand(sql, conn);
SqlDataAdapter ad = new SqlDataAdapter();
ad.SelectCommand = command;
ad.Fill(dt);
dt.Clear();
SqlDataAdapter adp=new SqlDataAdapter("select * from text1",conn);
adp.Fill(dt);
dataGridView1.DataSource=dt.DefaultView;
}
}
}
提示sa登陆失败,但是我的其它代码这么连接都没问题啊,不知错在哪里