Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing uniqueidentifier (GUID) from Adp to SQL Server

Status
Not open for further replies.

PWise

Programmer
Dec 12, 2002
2,633
US
I am trying to run this code from a Vba module


Code:
.....
cmd.CommandText = "Insert into ProvidersSelect(Providerid,newguid) Values (655," & me.TxtGUID & ")"
cmd.Execute
....
where me.TxtGUID ={94FB6132-8812-48A3-8997-DDA311DE23AF}
this is the error I get
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation

any help will be appreciated

Pwise

 
Looks like it's a string so needs to be in single quotes

Code:
cmd.CommandText = "Insert into ProvidersSelect(Providerid,newguid) Values (655, [COLOR=red]'[/color red]" & me.TxtGUID & "[COLOR=red]'[/color red])"

hth

 
ajrimmer:

Thanks for replying

Field newguid is of type uniqueidentifier

When I enclosed it in single quotes m get this error

Syntax error converting from a character string to uniqueidentifier.

I tried useing

Code:
cmd.CommandText = "Insert into ProvidersSelect(Providerid,newid) Values (" & ProviderId & "," & GUIDFromString(Me.NewId) & ")"

I get This error

Line 1: Incorrect syntax near '?'.

when i run

Code:
debug.print cmd.CommandText

it prints

Insert into ProvidersSelect(Providerid,newid) Values (655,????????)

and in profiler

Insert into ProvidersSelect(Providerid,newid) Values (655,????????)


Pwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top