kavvis
asked on
VBscript VB6.0 SQL
Hi I have a problem.. I must do this in vbscript because it´s in a software... but I can´f figure it all out.. I feel it´s more diffrent
whit vbscript then "vb.net"
Can I get som help...
I know that the SQL connection works.. I can delete lines.. I can write new lines
Now I can get one singel value
But I want to get all rows values...
DATABAS
Column
ID Names Age
2 Kalle 22
3 Nils 34
5 Olof 34
12 Klase 40
What I want to do is add all this diffrent names into a listbox och textbox, combox dropdownbox... whatever..
the simples of it...
Whit this code I can get one single value...
whit vbscript then "vb.net"
Can I get som help...
I know that the SQL connection works.. I can delete lines.. I can write new lines
Now I can get one singel value
But I want to get all rows values...
DATABAS
Column
ID Names Age
2 Kalle 22
3 Nils 34
5 Olof 34
12 Klase 40
What I want to do is add all this diffrent names into a listbox och textbox, combox dropdownbox... whatever..
the simples of it...
Whit this code I can get one single value...
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)
Dim rs
Dim results
Dim objConnection
Dim strConnectionString
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=TESTDB;UID=;PWD=;"
strSQL = "Select Names from TEST_DB"
'MsgBox(strSQL)
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSQL
End With
'objCommand.Execute
Set rs = objCommand.Execute
results = rs.Fields(0).Value
MsgBox(results)
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you! it all worked verry good.
Now I looking for how to add it to listbox or combox..
Now I looking for how to add it to listbox or combox..
Hi,
where do you want to have the combobox meaning what is the UI technology? ASP or HTML page?
Just create a new question, add this one as reference and we would all be looking forward to help you out.
Thanks.
KR
Rainer
where do you want to have the combobox meaning what is the UI technology? ASP or HTML page?
Just create a new question, add this one as reference and we would all be looking forward to help you out.
Thanks.
KR
Rainer
listbox and combobox controls have an AddItem method
rs.MoveNext after line 22 (before the loop).