SQL连接语句
using System.Data.SqlClient;using System.Data.Sql;SqlConnection con = new SqlConnection("Data Source=COMWBOY;uid=sa;pwd=123456;database=yiyuan"); //打开连接 con.Open(); //SQL语句 string str = "select * from Admin where userid='" + this.userid.Text + "'and password='" + this.password.Text + "'"; //建立数据库执行对象 SqlCommand com = new SqlCommand(str, con); SqlDataReader dr = com.ExecuteReader();
若在Data Source中只能赋值IP地址而不能赋值服务器名.那问题是出在SQL中.应该把验证方式该为混合模式