gconlon
Posts: 3
|
| Posted: 11/30/2004, 4:37 AM |
|
This has to be a simple problem that I just can not see the forrest for the treas
I have a security database (SQL VER 7) with a charactor ID filed. The below SQL search works perfectly if the ID filed ( Called DID in the Database) in the SQL database is numeric ie.. 64565 But if the ID field D65655 the below search crashes. Any Ideas what I am doing wrong.. Thanks in advance
Dim SQL
Dim RecordSet
Dim UserId
Dim UserName
Dim agency1
DIM SLEVEL
UserId =phone.enteredby.value
If UserID <> "" then
SQL = "SELECT DID, AGENCY,LEVEL1 FROM SECURITY WHERE did="&UserId
Set RecordSet = dbconnection1.Execute(SQL)
If dbconnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
UserName = CCGetValue(RecordSet, "DID")
AGENCY1 = CCGetValue(RecordSet, "AGENCY")
SLEVEL = CCGetValue(RecordSet, "LEVEL1")
End if
RecordSet.Close
Set RecordSet = Nothing
Else
Print "SQL Validation Procedure Execution Failed."
dbconnection1.Errors.Clear
End If
IF rtrim(AGENCY1)<>rtrim(phone.juris.VALUE) and rtrim(slevel)<>999 THEN phone.errors.adderror("YOU MAY NOT UPDATE ANOTHER AGENCIES RECORD")
End if
|
 |
 |
Stefano Chermaz
|
| Posted: 11/30/2004, 8:29 AM |
|
If you search for a not numeric field, you must include the apostrophe
before and after the field
SELECT DID, AGENCY,LEVEL1 FROM SECURITY WHERE did='STEFANO'
SQL = "SELECT DID, AGENCY,LEVEL1 FROM SECURITY WHERE did='"&UserId&"'"
|
|
|
 |
gconlon
Posts: 3
|
| Posted: 11/30/2004, 11:02 AM |
|
Stefano:
You hit the nail on the head, thank you so much for your time, I have been fumbling for 3 hours.
George
|
 |
 |
DonB
|
| Posted: 11/30/2004, 4:49 PM |
|
You should always use the ToSQL method of your data connection - it takes a
value and datatype and will correctly format the data (i.e., puts the
apostrophes around a string).
--
DonB
http://www.gotodon.com/ccbth
"gconlon" <gconlon@forum.codecharge> wrote in message
news:641acc3c5846da@news.codecharge.com...
> Stefano:
>
> You hit the nail on the head, thank you so much for your time, I have been
> fumbling for 3 hours.
>
> George
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|