I have fixed the variable issue it was just a typo
The last question is how would I display information from more than one column. I mean right now I am displaying first_name, how would I show last_name or all the data in the table.
Also is there a way if there are multiple results to set it up so that the user could select the correct rersponse.
Thanks
Use ODBC connection to a sybase database
Moderators: JRL, Dorian (MJT support)
Hi,
If you want another column then assign another variable and use the Fields object again for the appropriate field. e.g.
FirstName = rsCustomers.Fields("First_Name")
LastName = rsCustomers.Fields("Last_Name")
etc (I don't know your field names). You could do something like this:
FullName = rsCustomers.Fields("First_Name") & " " & rsCustomers.Fields("Last_Name")
You want more than one row? First your SQL statement would need to be less restrictive and then you can cycle through the rows with a loop and using MoveNext method. E.g:
do until rsCustomers.eof
CurrentName = rsCustomers.Fields("First_Name")
rsCustomers.MoveNext
loop
You want to cycle through each field of each row? Use "for each":
for each f in rsCustomers.FIelds
MsgBox f.value
next
The following example will display each field of each row in a message box (useless real-world example, but an example none-the-less):
do until rsCustomers.eof
for each f in rsCustomers.Fields
MsgBox f.value
next
rsCustomers.MoveNext
loop
More usefully you might want to pop the values into an array which you can then easily evaluate from within MacroScript.
There is an example of the above ideas in the CSV import script (it uses ADO - your connect string and SQL would be different but all the rest is valid): http://www.mjtnet.com/scripts.hts?display+121+
If you want another column then assign another variable and use the Fields object again for the appropriate field. e.g.
FirstName = rsCustomers.Fields("First_Name")
LastName = rsCustomers.Fields("Last_Name")
etc (I don't know your field names). You could do something like this:
FullName = rsCustomers.Fields("First_Name") & " " & rsCustomers.Fields("Last_Name")
You want more than one row? First your SQL statement would need to be less restrictive and then you can cycle through the rows with a loop and using MoveNext method. E.g:
do until rsCustomers.eof
CurrentName = rsCustomers.Fields("First_Name")
rsCustomers.MoveNext
loop
You want to cycle through each field of each row? Use "for each":
for each f in rsCustomers.FIelds
MsgBox f.value
next
The following example will display each field of each row in a message box (useless real-world example, but an example none-the-less):
do until rsCustomers.eof
for each f in rsCustomers.Fields
MsgBox f.value
next
rsCustomers.MoveNext
loop
More usefully you might want to pop the values into an array which you can then easily evaluate from within MacroScript.
There is an example of the above ideas in the CSV import script (it uses ADO - your connect string and SQL would be different but all the rest is valid): http://www.mjtnet.com/scripts.hts?display+121+
MJT Net Support
[email protected]
[email protected]
A question of variable
Hi Al,
Just an observation…
In your code you want to pass the Last name and retrieve the first name. Right?
Well, in your code:
Input>MemberLName,Enter Member Last Name:
VBEval>GetMemberName("%MemberName%"),MemberName
MessageModal>The Member Name Is : %CRLF% %CRLF% %MemberName% %MemberLName%
You pass %MemberName%" and return the result to the same named variable MemberName,
Yet, in your MessageModal> you use %MemberName% %MemberLName%, but I fail to see where you pass MemberLName to the VB Script in your Macro Scheduler code.
I think you want to do:
Input>MemberLName,Enter Member Last Name:
VBEval>GetMemberName("%MemberLName%"),MemberName
MessageModal>The Member Name Is : %CRLF% %CRLF% %MemberName% %MemberLName%
Yes?
Let me know if I was any help.
Respectfully,
Denis
Just an observation…
In your code you want to pass the Last name and retrieve the first name. Right?
Well, in your code:
Input>MemberLName,Enter Member Last Name:
VBEval>GetMemberName("%MemberName%"),MemberName
MessageModal>The Member Name Is : %CRLF% %CRLF% %MemberName% %MemberLName%
You pass %MemberName%" and return the result to the same named variable MemberName,
Yet, in your MessageModal> you use %MemberName% %MemberLName%, but I fail to see where you pass MemberLName to the VB Script in your Macro Scheduler code.
I think you want to do:
Input>MemberLName,Enter Member Last Name:
VBEval>GetMemberName("%MemberLName%"),MemberName
MessageModal>The Member Name Is : %CRLF% %CRLF% %MemberName% %MemberLName%
Yes?
Let me know if I was any help.
Respectfully,
Denis