ASP.NET and ACCESS problems

Node_Pointer

Limp Gawd
Joined
Mar 26, 2002
Messages
313
Here is my code

'-- Create and issue an SQL command through the database connection
SQLString = "Insert Into login ( username, password ) Values ( '@username', '@password' )"
DBCommand = New OleDbCommand(SQLString, DBConnection)

DBCommand.Parameters.Add( "@username", username.Text)
DBCommand.Parameters.Add( "@password", password.Text)

DBConnection.Open()
DBCommand.ExecuteNonQuery()
DBConnection.Close()

Apparently there is a problem with my INSERT INTO statement.

WHAT THE PROBLEM IS?
thanks :)
 
Access is an ornery pisshat when it comes to attempting to use real SQL with it...

You may want to consider h4x0ring up your query string statement like this:

SQLString = "Insert Into login ( username, password ) Values ( ' " & username.Text & ", ' " & password.text &" ' )"

Basically, instead of doing it as they teach in class (using the parameter builder thingy), I'm mimicing what I've seen in the real world- splicing variables into the SQL statement where necessary (i'm not terribly familiar with Access though.. i'm spoiled on M$ $QL $erver).

One other thing that may be buggering you is that Access uses " instead of ' as its string delimiter....
 
I had similar problems myself when trying to use Access with ASP.NET several months ago. I never could get it to work so I switched to MySQL. I would rather have gone with SQL Server, but the web site I was working on has two stipulations: 1. Must use Microft ASP technology instead of PHP and 2. Must not cost any money.
 
What if you change it to

SQLString = "Insert Into login ( username, password ) Values ( @username, @password )"

--note I removed the single quotes
 
Back
Top