Need help
Moderators: Dorian (MJT support), JRL
Need help
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
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.
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.
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]
[email protected]
still i have prob
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
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.
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.
I can see only one error in your script. Remove "as string" from the Dim SQLString line.
MJT Net Support
[email protected]
[email protected]
Also since the function takes no parameters remove the parentheses from the function declaration.
MJT Net Support
[email protected]
[email protected]
empty message window
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
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.
Last edited by aysha on Tue Feb 01, 2011 9:31 am, edited 1 time in total.
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%
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]
[email protected]
thax a lot
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
again thank u very much for help
Aysha
________
Ford Power Stroke engine history