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.
Author |
Topic |
kobiks
Starting Member
2 Posts |
Posted - 2007-12-22 : 08:29:59
|
Hello thereIm 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 aheadso i wrote the following script:-----------------------------------Set wshshell = WScript.CreateObject("WScript.Shell")'Foretells of a connection to the databaseSet cnn=CreateObject("ADODB.Connection") 'Foretells of a connection to a RecordsetSet objRecordSet = CreateObject("ADODB.Recordset")'Opens the Databasecnn.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.CloseWScript.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" |
 |
|
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 objConnectionDim strConnDim strSQLDim VAR'object variable for ADODBSet objConnection = CreateObject("ADODB.Recordset")'the connection stringstrConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= D:\UPC\Convert KANA\db2.mdb"'populate the ADODB connection stringobjConnection.ConnectionString = strConn'populate the SQL statementstrSQL = "SELECT Top 1 HOUSE_NUMBER_EXTENSION_LFI FROM [campaing 3] WHERE [campaing 3].CUSTOMER_NUMBER_CUST='503';"VAR = objConnection.Execute strSQL, , 1objConnection.CloseSet 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. |
 |
|
kobiks
Starting Member
2 Posts |
Posted - 2007-12-22 : 12:07:52
|
sorry ,i will take it outThe error message is:"Expected end of statmentE" code 800A0401quote: 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"
|
 |
|
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 outThe error message is:"Expected end of statmentE" code 800A0401quote: 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. |
 |
|
|
|
|
|
|