Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Variable in VBScript in MS Access SQL insert

$
0
0

Hi,

I am having an issue getting the syntax right for an INSERT statement in my VBScript. Ultimately, this script will take the columns and row 1 from my data sheet and insert them. Does anyone know the exact syntax for the INSERT?

Currently I have the following array...

For each field In myArray
	vColVariable = vColVariable & """" & ", " & """" & field
next


Then a second array that grabs the row values and loads into a variable as well...

For each field In myArray2
	vRowVariable = vRowVariable & ", " & field
next

Then...

		Dim objCon,objRs
		Set objCon = createobject("ADODB.connection")
		Set objRs = createobject("ADODB.recordset")

		objCon.Provider = "microsoft.jet.oledb.4.0"
		objCon.Open "Path\ScriptData.mdb"

		sqStr = "INSERT INTO Auto_Driver_Test ('"""&vColVariable&"""') VALUES ('"""&vRowVariable&"""');"
		print sqStr

		objRs.Open sqStr, objCon


		Set objCon = nothing
		Set objRs = nothing

Trying to get the right combination of single and double quotes with & is where I'm having the issue. I keep getting the error "Invalid bracketing of name.. etc etc etc"

Any help would be great.




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>