c#连接数据库,代码编写
大神们看看,哪里有错啊,在线急等,帮帮忙string connStr = "Data Source=WIN-BHEK6HEOO9A;Initial Catalog=bishe_DB;Integrated Security=True";
SqlConnection conn = new SqlConnection(connStr);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
string sqlstr="SELECT P,PV,V FROM ZCCL WHERE CL like "+comboBox5.Text+"";
SqlCommand cmd = new SqlCommand(sqlstr,conn);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
string aa = dr["P"].ToString();
string bb = dr["V"].ToString();
string cc = dr["PV"].ToString();
double a = Convert.ToDouble(aa);
double b = Convert.ToDouble(bb);
double c = Convert.ToDouble(cc); combobox5.text. 要单引号,你还报了什么错
页:
[1]