string sql = "select ID,ForceArea,ditchName_1 from Debris_flow_1 where unifiedCode_5=" + markl + "";
string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Coll.mdb;Jet OLEDB:Database Password=*****;";
System.Data.OleDb.OleDbConnection myConnection = new System.Data.OleDb.OleDbConnection(connStr);
myConnection.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = myConnection;
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
OleDbDataReader sde = cmd.ExecuteReader();
textBox1.Text = sde["ID"].ToString();
textBox2.Text = sde["ForceArea"].ToString();
textBox3.Text = sde["ditchName_1"].ToString();
myConnection.Close();
不知道哪儿出问题了,执行到 OleDbDataReader sde = cmd.ExecuteReader();这个语句时候,就跳出了,求教大神这是什么原因啊??
------解决思路----------------------
看看sql是否正确
------解决思路----------------------
跳出就是报错了,楼主没有捕获异常么,具体原因就在其中.
仅有一个SQL语句,猜测就是它有问题.
------解决思路----------------------
string sql = "select ID,ForceArea,ditchName_1 from Debris_flow_1 where unifiedCode_5='" + markl + "'";
看你数据unifiedCode_5是字符串啊,那要加引号