Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 VBS + SQL command

Author  Topic 

kobiks
Starting Member

2 Posts

Posted - 2007-12-22 : 08:29:59
Hello there

Im actually making a select command and want to asign the result to a varaible so i can use it later,but i always get en error,
Somebody can show the way how to implement it?

Thanks ahead

so i wrote the following script:
-----------------------------------

Set wshshell = WScript.CreateObject("WScript.Shell")

'Foretells of a connection to the database
Set cnn=CreateObject("ADODB.Connection")

'Foretells of a connection to a Recordset
Set objRecordSet = CreateObject("ADODB.Recordset")

'Opens the Database

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= D:\UPC\Convert KANA\db2.mdb"
Dim VAR="SELECT HOUSE_NUMBER_EXTENSION_LFI FROM [campaing 3] WHERE [campaing 3].CUSTOMER_NUMBER_CUST='503';"

'Closes everything

cnn.Close
WScript.Quit

------------------------------------


Thanks a

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-22 : 10:48:20
What is the error?
And moderator, please move topic to Access forum since this is not a working script.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-12-22 : 11:57:04
I think the syntax is quite a bit off. The error is likely related to it not working at all.

You create the ADODB object in a variable called objRecordSet, but don't refer to that again.

You declare and set the variable VAR in the same line which doesn't work in VBScript (works in C#)



Dim objConnection
Dim strConn
Dim strSQL
Dim VAR

'object variable for ADODB
Set objConnection = CreateObject("ADODB.Recordset")
'the connection string
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= D:\UPC\Convert KANA\db2.mdb"

'populate the ADODB connection string
objConnection.ConnectionString = strConn

'populate the SQL statement
strSQL = "SELECT Top 1 HOUSE_NUMBER_EXTENSION_LFI FROM [campaing 3] WHERE [campaing 3].CUSTOMER_NUMBER_CUST='503';"


VAR = objConnection.Execute strSQL, , 1

objConnection.Close

Set objConnection = Nothing



That may not be exactly right, but it is way closer than the posted code.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

kobiks
Starting Member

2 Posts

Posted - 2007-12-22 : 12:07:52
sorry ,i will take it out
The error message is:"Expected end of statmentE" code 800A0401

quote:
Originally posted by Peso

What is the error?
And moderator, please move topic to Access forum since this is not a working script.


E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-12-22 : 17:45:28
quote:
Originally posted by kobiks

sorry ,i will take it out
The error message is:"Expected end of statmentE" code 800A0401

quote:
Originally posted by Peso

What is the error?
And moderator, please move topic to Access forum since this is not a working script.


E 12°55'05.25"
N 56°04'39.16"






Did you not see my post? The error message alone is not the problem with your code.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -