View Single Post
Old Feb 24th, 2007, 7:16 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by Abyss View Post
Just out of interest, what would be the correct way to build the SQL string? This database is under minimal risk to be targetted by a malicious user though it would be good to know for the future.
I haven't worked in VB.NET much, or really at all, but I suspect it would be something like this:
vbnet Syntax (Toggle Plain Text)
  1. Dim command As ADODB.Command
  2. Dim usernameParam As ADODB.Parameter
  3.  
  4. Set command = New ADODB.Command
  5.  
  6. command.CommandText = "SELECT * FROM users WHERE username = @username"
  7. command.ActiveConnection = CurrentProject.Connection
  8.  
  9. Set usernameParam = New ADODB.Parameter
  10.  
  11. usernameParam.ParameterName = "username"
  12. usernameParam.Type = adVarChar
  13. usernameParam.Value = "Bob"
  14.  
  15. command.Parameters.Append usernameParam
  16.  
  17. Set rs = command.Execute()
Long winded, I know. Maybe there's a more concise way.
Arevos is offline   Reply With Quote