![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | "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 Specs![]() |
| | #2 (permalink) |
| | 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 > 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 Specs![]() |
![]() |
| 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 | |||