using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection MyConnection = new SqlConnection(@"server=localhost;database=aaa.mdf1;uid=;pwd=;Connect Timeout=30;database=aaa;");
MyConnection.Open();
SqlDataAdapter sd = new SqlDataAdapter("SELECT * FROM Table1", MyConnection);
SqlCommandBuilder ssd = new SqlCommandBuilder(sd);
DataSet thisDset = new DataSet();
sd.Fill(thisDset, "Table1");
SqlCommand Command = new SqlCommand();
SqlDataReader reader = Command.ExecuteReader();
DataRow findrow = thisDset.Tables["Table1"].Rows.Find("111");
if (findrow == null)
{
if (MessageBox.Show("11111" + "用户名不存在", "错误信息!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
== DialogResult.OK)
{
MessageBox.Show("qqqqqqqqqq");
}
else
{
MessageBox.Show("1111111111111111");
}
}
else
{
MessageBox.Show("系统致命错误!", "错误信息!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
}
}
}
错在哪里啊.为什么服务器连不上.