Insert Statement

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
jtsy
Newbie
Posts: 7
Joined: Tue Jul 17, 2007 9:09 am

Insert Statement

Post by jtsy » Tue Jul 17, 2007 11:07 am

Hi sorry i got another problem now I tried to perform an Insert Into. 'Temp' variable contains values that i retrieved from notepad. However, the data that was inserted into the database is always (1, blank space). Is it because 'temp' is outside VBSTART and VBEND? if so, how do i go about correcting it? Thanks a lot for your help! below is part of the code

GetWindowText>Untitled - Notepad,temp

VBSTART
Dim ConnectionString : ConnectionString="Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; USER=root; PASSWORD=*****; OPTION=3;"
Dim MyDB
Set MyDB=CreateObject("ADODB.Connection")

MyDB.Open ConnectionString

Dim rs : rs = MyDB.Execute("INSERT INTO carriertest VALUES('1','"&temp&"')")

VBEND

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jul 17, 2007 12:34 pm

Have you looked at the examples and help file? You're mixing MacroScript and VBScript. So do something like this:

Code: Select all

VBSTART
Sub DoTheInsert(TheValue)
  Dim ConnectionString
  ConnectionString="Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; USER=root; PASSWORD=*****; OPTION=3;"
  Dim MyDB
  Set MyDB=CreateObject("ADODB.Connection")
  
  MyDB.Open ConnectionString

  Dim rs
  rs = MyDB.Execute("INSERT INTO carriertest VALUES('1','"&TheValue&"')")
End Sub
VBEND

GetWindowText>Untitled - Notepad,temp
VBRun>DoTheInsert,temp
Please search this forum and look at the examples showing vbscript being used inside Macro Scheduler. Also look at the VBScript sample(s) that come with the software, plus the examples in the help file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

jtsy
Newbie
Posts: 7
Joined: Tue Jul 17, 2007 9:09 am

Post by jtsy » Tue Jul 17, 2007 12:38 pm

ok! thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts