Moti Mashiah
asked on
C# syntax issue
Hi Guys ,
I'm trying to fill up some of my combobox with the database and I'm getting error "Incorrect syntax near the keyword'Order'.
Please review my code:
I'm trying to fill up some of my combobox with the database and I'm getting error "Incorrect syntax near the keyword'Order'.
Please review my code:
void Fillcombo()
{
string conn = "Data Source=srv-db-02;Initial Catalog=rmsmasterdbtest;Persist Security Info=True;User ID=sa;Password=45Tadabase";
string Query = "select * from rmsmasterdbtest.dbo.Order ;";
SqlConnection Myconn = new SqlConnection(conn);
SqlCommand cmdDataBase = new SqlCommand(Query, Myconn);
SqlDataReader Reader;
try
{
Myconn.Open();
Reader = cmdDataBase.ExecuteReader();
while (Reader.Read())
{
string ids = Reader.GetInt32(Reader.GetOrdinal("ID")).ToString();
comboBox1.Items.Add(ids);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
Myconn.Close();
}
ASKER
What I should do I can't change the table name this is my production database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much I just did something like this "select * from [Order]
ASKER
was really helpful and save me a lot of time.
Glad I could help!
PS: now you can go back at your previous questions and use the order table instead of the workarounds you used.
PS: now you can go back at your previous questions and use the order table instead of the workarounds you used.
http://msdn.microsoft.com/en-us/library/ms189822%28v=sql.105%29.aspx
HTH,
Dan