Fatal error: Call to a member function fetchAll() on boolean in C:\xampp\htdocs\pdo\pdoDome.php on line 50是什么原因??源代码//1.连接数据库try{$pdo = new PDO("mysql:host=localhost;dbname = test;","root","");}catch (PDOException $e){die("数据库连接失败".$e->getMessage());}print_r($pdo);//2.执行query(查询)返回一个预处理对象$sql = "select * from users";$stmt = $pdo->query($sql);$list = $stmt->fetchAll(PDO::FETCH_ASSOC);//解析数据print_r($list);
1 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
SqlConnection con = new SqlConnection
con.Open();
string sqlstr = "sql语句";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);
DataSet ds= new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
con.Close();
- 1 回答
- 0 关注
- 156 浏览
添加回答
举报
0/150
提交
取消