问题描述
嗨
当我使用Database Access在vs.net 2012中编译我的网站项目时,它会在此行显示错误OleDbDataReader reader = command.ExecuteReader();
错误是:SELECT语句包含拼写错误或缺失的保留字或参数名称,或者标点符号不正确。
我该怎么做才能解决这个错误?
-------------- ----------------
这是我的代码:
Hi
When i compile my web site project in vs.net 2012 with Database Access it displays an error in this line " OleDbDataReader reader = command.ExecuteReader();"
The error is : " The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect."
what should i do for solving this error ?
------------------------------
This is my code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string connectionString, queryString;
connectionString = ConfigurationManager.ConnectionStrings["ostanConnectionString"].ToString();
queryString = "SELECT FROM situation where state ='" + DropDownList1.SelectedValue + "'";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
DropDownList2.Items.Clear();
while (reader.Read())
DropDownList2.Items.Add(reader["city"].ToString());
reader.Close();
connection.Close();
}
}
}
感谢您的帮助
Davood
Thanks for any help
Davood
推荐答案
这篇关于OleDbDataReader reader = command.ExecuteReader();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!