Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - "Object required" message in VB Script

Reply
 
Old 08-07-2009   #1 (permalink)
childofthe1980s


 
 

"Object required" message in VB Script

Hello:

I have a VB script that is designed to update the IV10002 table in SQL. I
keep getting an "obejct required" error on the SQL script. What am I doing
wrong?

Below is my entire script:


'Create a new connection

Set objRec = CreateObject("ADODB.Recordset")

Set objConn = CreateObject("ADODB.Connection")

objConn.ConnectionString = "Provider=MSDASQL;DSN=Dynamics GP01;Initial
Catalog=TNEW;User Id=sa;Password=1qaz2wsx!"

objConn.Open


'Run the SQL script
Dim sSQL
Set sSQL = "update IV10002 set EXPNDATE = '" & SourceFields("LOTS.EXPIRE") &
"'"


'Execute sSQL

objConn.Execute(sSQL)



'Close the connection

objConn.Close


My System SpecsSystem Spec
Old 08-07-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: "Object required" message in VB Script


"childofthe1980s" <childofthe1980s@xxxxxx> wrote in
message news:51A5AF75-5164-400A-9276-092CF7E6ACE5@xxxxxx
Quote:

> Hello:
>
> I have a VB script that is designed to update the IV10002 table in SQL. I
> keep getting an "obejct required" error on the SQL script. What am I
> doing
> wrong?
>
> Below is my entire script:
>
>
> 'Create a new connection
>
> Set objRec = CreateObject("ADODB.Recordset")
>
> Set objConn = CreateObject("ADODB.Connection")
>
> objConn.ConnectionString = "Provider=MSDASQL;DSN=Dynamics GP01;Initial
> Catalog=TNEW;User Id=sa;Password=1qaz2wsx!"
>
> objConn.Open
>
>
> 'Run the SQL script
> Dim sSQL
> Set sSQL = "update IV10002 set EXPNDATE = '" & SourceFields("LOTS.EXPIRE")
> &
> "'"
>
>
> 'Execute sSQL
>
> objConn.Execute(sSQL)
>
>
>
> 'Close the connection
>
> objConn.Close
>
You don't say which line raises the error, but I suspect the Set sSQL line
is the culprit. You assign a string to the variable sSQL, so the Set keyword
should not be used. Instead use:

sSQL = "update IV10002 set EXPNDATE = '" & SourceFields("LOTS.EXPIRE") & "'"

However, what is SourceFields? Is that a function defined elsewhere? If
SourceFields is not defined that will raise an error. Also, you never use
objRec.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
do not display "ERRORS" when running script without using $erroractionpreference = "SilentlyContinue" PowerShell
runtime error: "Object required" VB Script
Separate hashtable vs $alist | where-object { "key" = "value" } versus something else? PowerShell
"Required driver could not be installed" message preventing beta 2 Vista installation & setup
False IE doc body error - "Object reference not set to an instance of an object" PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46