ayan check this out. (or anyone else)
This is the code that I got. Justin is the database name, auto is the table that im looking in, and ItemNumber is what I want to put in the combo Box. Im using my local server group and my server name is JNASI. When I run this I get no errors but my combo box is not populated. Any advise?
Thanks
Imports System.data.sqlclient
Imports System.Data
Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As New SqlConnection
Dim mycommand As New SqlCommand
Dim myDS As DataSet = New DataSet
Dim Mydatagrid As New DataGrid
Dim da As New SqlDataAdapter
Dim objConnection As SqlConnection = New SqlConnection("server=(JNASI);database=justin;user id=sa;password=")
Dim cmdtext As String = "select itemnumber from auto"
Dim dt As New DataTable("auto")
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItemNumber.SelectedIndexChanged
'open the database connection
cn = New SqlConnection("integrated security=true;initial catalog=auto")
da.SelectCommand = New SqlCommand(cmdtext, cn)
da.Fill(dt)
With cboItemNumber
.DataSource = dt
.DisplayMember = "ItemNumber"
End With
End Sub
End Class