|
-
Feb 9th, 2003, 04:27 AM
#1
Thread Starter
Hyperactive Member
uh? error adding SQL db fields to listbox
What is wrong with my code?
The 'MB' database had 20 fields, but the only thing that will be added to the listbox is 20x 'ADODB.Internalfield'
Please help me 
VB Code:
Dim objConn As ADODB.Connection = New ADODB.Connection()
Dim objRs As ADODB.Recordset = New ADODB.Recordset()
Dim i As Integer
objConn.ConnectionString = "Provider=SQLOLEDB;data Source=CC200392-B; Initial Catalog=MB;User Id=sa;Password=***;"
objConn.Open()
objRs.Open("Select * from Users", objConn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
For i = 0 To objRs.Fields.Count - 1
ListBox1.Items.Add(objRs.Fields(i))
Next
objRs.Close()
objRs = Nothing
objConn.Close()
objConn = Nothing
There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me
-
Feb 9th, 2003, 01:49 PM
#2
Thread Starter
Hyperactive Member
There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me
-
Feb 9th, 2003, 03:16 PM
#3
Hyperactive Member
Re: uh? error adding SQL db fields to listbox
VB Code:
For i = 0 To objRs.Fields.Count - 1
ListBox1.Items.Add(objRs.Fields(i))
Next
objRs.Close()
objRs = Nothing
objConn.Close()
objConn = Nothing
try ListBox1.Items.Add(objRs.Fields(i).name)
also if you are just looking for the field names then change your sql to read "select top 1 from ....." rather than have it grabbing all records.
-
Feb 9th, 2003, 03:57 PM
#4
Thread Starter
Hyperactive Member
thanks, problem solved
that was simple
There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|