D
Dafydd Giddins
Hi
I set up a new instance of SQL Server using the developer
edition CD and set up a datbase called AMA, table called
user with two fields called userid (the primary key) and
username (a string). Wheni run the code i get the
following error message
Incorrect Syntax near the keyword 'user'.
What am i missing?
Regards
Dafydd
Code is below
SqlConnection conn = new
SqlConnection
("server=localhost;database=AMA;uid=sa;pwd=password");
try
{
conn.Open ();
SqlCommand cmd = new
SqlCommand ("select * from user", conn);
SqlDataReader reader =
cmd.ExecuteReader ();
while (reader.Read ())
Console.WriteLine
(reader["username"]);
}
catch (SqlException ex)
{
Console.WriteLine
("Error:" + ex.Message);
}
finally
{
conn.Close ();
}
I set up a new instance of SQL Server using the developer
edition CD and set up a datbase called AMA, table called
user with two fields called userid (the primary key) and
username (a string). Wheni run the code i get the
following error message
Incorrect Syntax near the keyword 'user'.
What am i missing?
Regards
Dafydd
Code is below
SqlConnection conn = new
SqlConnection
("server=localhost;database=AMA;uid=sa;pwd=password");
try
{
conn.Open ();
SqlCommand cmd = new
SqlCommand ("select * from user", conn);
SqlDataReader reader =
cmd.ExecuteReader ();
while (reader.Read ())
Console.WriteLine
(reader["username"]);
}
catch (SqlException ex)
{
Console.WriteLine
("Error:" + ex.Message);
}
finally
{
conn.Close ();
}