连接sql数据库:
private void Form1_Load(object sender, System.EventArgs e)
{
string source="server=127.0.0.1;"+"uid=sa;pwd=sa;"+"database=DatabaseName";
string select ="select * from TableName";
SqlConnection conn = new SqlConnection(source);
SqlDataAdapter da= new SqlDataAdapter(select,conn);
DataSet ds= new DataSet();
da.Fill(ds,"TableName");
dataGrid1.SetDataBinding(ds,"TableName");
}
************************************************************
连接access