Need help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

Need help

Post by aysha » Thu Apr 28, 2005 9:24 am

i want to extract table value in some varialbe and want to show that value.

i'ev used VB script but in ASP ,Macro Scheduler commends are diff
can some body tell me that how i open a database and table in Macro and how i show that table value :?: .

thax and regrads,
aysha
________
buy herbalaire
Last edited by aysha on Tue Feb 01, 2011 9:31 am, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Apr 28, 2005 9:54 am

What kind of database? There is a tutorial explaining how to do so using Access/ADO/ODBC here:
http://www.mjtnet.com/index.htm?vbsdb.html

This example uses Access but will work with any other ODBC data source.
MJT Net Support
[email protected]

aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

still i have prob

Post by aysha » Fri Apr 29, 2005 5:49 am

Thanks for help but still i have some prob
i wrote the code below:

VBSTART

Function GetCustomerName()

Dim SQLString as string
dim rsCustomers
dim MyDB

set MyDB = CreateObject("ADODB.Connection")
MyDB.Open "DSNCUS"

SQLString = "select CustomerName from Customers"
set rsCustomers = MyDB.Execute(SQLString)


If Not rsCustomers.EOF then
GetCustomerName = rsCustomers.Fields("CustomerName")
Else
GetCustomerName = "Not Found"
End if


MyDB.Close

End Function

VBEND

VBEval>GetCustomerName(),CustomerName
MessageModal>The Customer Name Is : %CRLF% %CRLF% %CustomerName%

but an error occur that
Specifeid Window "MyDB=CreateObject("ADODB.Connection")"Not present.....
after this when i click on Ignor then another error occur "Missing IF/ENDIF
now lz tell me how do correct these errors

regards,
aysha
________
buy iolite vaporizer
Last edited by aysha on Tue Feb 01, 2011 9:31 am, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Apr 29, 2005 6:45 am

Can't for the life of me imagine why you'd get that error, unless you have removed the VBSTART/VBEND lines at some point causing Macro Scheduler to try to interpret the VBScript as native code.

I can see only one error in your script. Remove "as string" from the Dim SQLString line.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Apr 29, 2005 7:25 am

Also since the function takes no parameters remove the parentheses from the function declaration.
MJT Net Support
[email protected]

aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

empty message window

Post by aysha » Fri Apr 29, 2005 7:31 am

i have removed 'As string'
now message window with label "customer name is:" is occur

why it doent show the value,even table contain a record.
________
buy volcano vaporizer
Last edited by aysha on Tue Feb 01, 2011 9:31 am, edited 1 time in total.

aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

Post by aysha » Fri Apr 29, 2005 7:32 am

i have removed the parenthesis but still it show no value. :cry:
________
Jaguar XJR Sportscars
Last edited by aysha on Tue Feb 01, 2011 9:31 am, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Apr 29, 2005 7:34 am

LOL. Goodness knows what you've done. I have just replied to your support email. The following script has been verified, tested and works:

VBSTART

Function GetCustomerName

Dim SQLString
dim rsCustomers
dim MyDB

set MyDB = CreateObject("ADODB.Connection")

MyDB.Open "DSNCUS"

set rsCustomers = CreateObject("ADODB.recordset")

SQLString = "select CustomerName from Customers"

set rsCustomers = MyDB.Execute(SQLString)

If Not rsCustomers.EOF then
GetCustomerName = rsCustomers.Fields("CustomerName")
Else
GetCustomerName = "Not Found"
End if

MyDB.Close

End Function
VBEND

VBEval>GetCustomerName(),CustomerName
MessageModal>The Customer Name Is : %CRLF% %CRLF% %CustomerName%
MJT Net Support
[email protected]

aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

thax a lot

Post by aysha » Fri Apr 29, 2005 7:52 am

script have run successfuly but some time i get that errors which i mentioned in email ,i dont know why that error some time occur and some time not.

again thank u very much for help

Aysha :)
________
Ford Power Stroke engine history

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