-
July 20th, 2009, 04:50 AM
#1
List the fields in combo box from SQL Server
Hi,
I used PostgreSQL and i want to populate its fields in combo box.
Is anyone know how to make it. .
Please help me. . . it is for my project. . :icon_sad:
Here is my code:
Code:
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sSQL As String
Dim IvAR As Integer
Set conn = New ADODB.Connection
conn.ConnectionString = connString
conn.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=PostgreSQL30;Initial Catalog=PostgreSQL"
Set rst = New ADODB.Recordset
rst.ActiveConnection = conn
rst.CursorLocation = adUseClient
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Fields = "inventory"
rst.Open
If rst.BOF = False Then
Combo1.Clear
For IvAR = 0 To rst.Fields.Count - 1
Combo1.AddItem rst.Fields(IvAR).Name
Combo1.ItemData(Combo1.NewIndex) = IvAR
Next IvAR
If Combo1.ListCount > 0 Then
Combo1.ListIndex = 1
End If
End If
, , Is this correct or not. . if not. . please help me to correct the codes. . .
I hope you help me. . .
Thanks in advance. . .
Last edited by HanneSThEGreaT; July 20th, 2009 at 09:39 AM.
Reason: Code Tags!
Tags for this Thread
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
|