Hello Experts!
I am attempting to use the OleDbCommand.Ex ecuteScaler() function within my
ASP.NET C# web page to perform a simple validation, but receive the
following error:
"Incorrect syntax near the keyword 'DEFAULT'"
The form has 2 fields on it, called tb_username and tb_password. (see code
snippet below).
The SQL Server table is called _users and has a number of columns, 2 of
which I am reading: username and password.
I've searched the net for any clues on this but so far none of the items
I've found were relavent to what I was doing. Can anyone shed any light on
this?
Many thanks!
=== here is my code ====
private bool ValidateLogin()
{
// set the connection string
oleDbConnection _login.Connecti onString = C_Constants.g_s DSN;
// add parameters to the query
oleDbCommand_lo gin.Parameters. Add("@user",Sys tem.Data.OleDb. OleDbType.VarWC har,25,tb_usern ame.Text); oleDbCommand_lo gin.Parameters. Add("@pass",Sys tem.Data.OleDb. OleDbType.VarWC har,25,tb_passw ord.Text); oleDbCommand_lo gin.CommandText = "Select username from _users whereusername=? AND password=?"; // open the connection oleDbConnection _login.Open(); // execute the query oleDbCommand_lo gin.Connection = oleDbConnection _login; object objResults = oleDbCommand_lo gin.ExecuteScal ar(); <--- errormessage occurs here // close the connection oleDbConnection _login.Close(); if (objResults==nu ll) { return false; } return true;}
I am attempting to use the OleDbCommand.Ex ecuteScaler() function within my
ASP.NET C# web page to perform a simple validation, but receive the
following error:
"Incorrect syntax near the keyword 'DEFAULT'"
The form has 2 fields on it, called tb_username and tb_password. (see code
snippet below).
The SQL Server table is called _users and has a number of columns, 2 of
which I am reading: username and password.
I've searched the net for any clues on this but so far none of the items
I've found were relavent to what I was doing. Can anyone shed any light on
this?
Many thanks!
=== here is my code ====
private bool ValidateLogin()
{
// set the connection string
oleDbConnection _login.Connecti onString = C_Constants.g_s DSN;
// add parameters to the query
oleDbCommand_lo gin.Parameters. Add("@user",Sys tem.Data.OleDb. OleDbType.VarWC har,25,tb_usern ame.Text); oleDbCommand_lo gin.Parameters. Add("@pass",Sys tem.Data.OleDb. OleDbType.VarWC har,25,tb_passw ord.Text); oleDbCommand_lo gin.CommandText = "Select username from _users whereusername=? AND password=?"; // open the connection oleDbConnection _login.Open(); // execute the query oleDbCommand_lo gin.Connection = oleDbConnection _login; object objResults = oleDbCommand_lo gin.ExecuteScal ar(); <--- errormessage occurs here // close the connection oleDbConnection _login.Close(); if (objResults==nu ll) { return false; } return true;}
Comment