ASP.NET对ACCESS数据库进行操作,报from子句语法错误
stringmyConnectionString=System.Configuration.ConfigurationManager.AppSettings["ConnS...
string myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnString"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";";
string mySelectQuery = "select * from user";//查询语句
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myConnection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (myReader.Read())
{
Console.WriteLine(myReader.GetString(0));
//GetString(0,1,2....)
}
myReader.Close();
我开始还真的以为是什么SQL语句错了,所以改成这个简单的查询 展开
string mySelectQuery = "select * from user";//查询语句
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myConnection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (myReader.Read())
{
Console.WriteLine(myReader.GetString(0));
//GetString(0,1,2....)
}
myReader.Close();
我开始还真的以为是什么SQL语句错了,所以改成这个简单的查询 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询