Hi! When my login form is loaded, I wish to retrieve the list of usernames from the database login to a combo box on the login form. unfortunately I am stuck with this error messsage " syntax error in FROM clause". Below is my codes.. help me out please
Thank you.
String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:/Documents and Settings/Farheen/My Documents/login.mdb";
//create and open the connection
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM user";
//set up the adapter
OleDbDataAdapter da = new OleDbDataAdapter("Select UserName from user",conn);
da.SelectCommand = cmd;
//create the dataset
DataSet ds = new DataSet();
da.Fill(ds);
cbo_Username.DisplayMember = "UserName";
cbo_Username.DataSource = ds.Tables[0];