新白痴求问??搞了好久还是想不通!!!
怎么就通不过调试呢???大家看个图,,在网上搜了,好象这个问题很普遍,,,程序代码:
private void label6_Click(object sender, EventArgs e) { string name = ""; int age =0; string sex = ""; string address = ""; string connString = "Data Source=JIANGXIHUANG;Initial Catalog=PersonalInformation;User ID=sa;Password=p@ssw0rd"; SqlConnection connection = new SqlConnection(connString); string sql = "select name,age,sex,address form PersonInfo" + "where name='趙靈兒 '"; try { connection.Open(); SqlCommand cmd = new SqlCommand(sql, connection); SqlDataReader datareader = cmd.ExecuteReader(); //提示错误的箭头指向这行 if (datareader.Read()) { name = datareader.GetString(0); age = datareader.GetInt32(1); sex = datareader.GetString(2); address = datareader.GetString(3); } textBox1.Text = name; textBox2.Text = age.ToString (); textBox3.Text = address; if (sex == "男") { radioButton1.Checked = true; } else { radioButton2.Checked = true; } datareader.Close(); } catch (DataException dataException) { MessageBox.Show(dataException.ToString()); } finally { connection.Close(); } }
调试时出现这个错误:Message="第 1 行: 'PersonInfowhere' 附近有语法错误。"