| | |
help in Sql syntax in ADODB data connenction
Thread Solved
![]() |
•
•
Join Date: Feb 2007
Posts: 11
Reputation:
Solved Threads: 0
I am using a ADODB connection to connect to an access database and am using an SQL string as the comandtext....but i need to check the validity of wat i have typed.....here is the sql statement..
here i want to encorporate the use of check for a text feild...am i using the right Sql syntax here....as in can i jus refer to txtusername.text or do i have to use it like $txtusername.text or soemthing.....Plzz Help
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim cmdcommand as new adodb.command With cmdCommand .ActiveConnection = conConnection .comanttext = "select * from Login where username = txusername.text" .CommandType = adCmdText End With
here i want to encorporate the use of check for a text feild...am i using the right Sql syntax here....as in can i jus refer to txtusername.text or do i have to use it like $txtusername.text or soemthing.....Plzz Help
•
•
Join Date: Feb 2007
Posts: 114
Reputation:
Solved Threads: 8
For starters lets look at the SQL statement line
This is not using the textbox value, the correct syntax for using the control is
This still has a problem as SQL requires quote delimiters for string fields, hence we would add that to the string thus
And finally to safely pass this without allowing for a SQL injection attack we would ensure the textbox has no apostrophy that could damage the database
That should just about do it
D
.comanttext = "select * from Login where username = txusername.text"This is not using the textbox value, the correct syntax for using the control is
.comanttext = "select * from Login where username = " & txusername.text This still has a problem as SQL requires quote delimiters for string fields, hence we would add that to the string thus
.comanttext = "select * from Login where username = '" & txusername.text & "'" And finally to safely pass this without allowing for a SQL injection attack we would ensure the textbox has no apostrophy that could damage the database
.comanttext = "select * from Login where username = '" & replace(txusername.text, "'", "''") & "'" That should just about do it
D
•
•
Join Date: Feb 2007
Posts: 28
Reputation:
Solved Threads: 3
You may want to check out these Free VB6 Database Tutorials.
![]() |
Similar Threads
- Display data in separate controls (SQL) (VB.NET)
- Convert XML data to sql table through coding in ASP.Net2.0 (IT Professionals' Lounge)
- Identity Column Problem in MS SQL Server when moving data from using Bulk Copy (MS SQL)
- radio button ASP question?? (ASP)
- Dummy in VB (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: similar of paintpicture
- Next Thread: How do I open existing excel document using vb6?
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





