日期:2014-05-17 浏览次数:21238 次
public partial class Form1 : Form
{
SqlConnection occ = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\123.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand ocm;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
occ.Open();
string sql = "select * from userinfo where Login=@log";
//ocm = new OleDbCommand(sql, occ);
ocm = new SqlCommand(sql, occ);
ocm.Parameters.AddWithValue("@log", tbuser.Text.ToString());
//OleDbDataReader ldr = ocm.ExecuteReader();
SqlDataReader ldr = ocm.ExecuteReader();
if (ldr.Read())
{
ldr.Close();
}
occ.Close();
}
}