1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
'prepare the connection properties' Dim con As New SqlConnection Dim sqlstr As String Dim da As New SqlDataAdapter Dim ds As New DataSet 'prepare your connection string' con = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersED-CARLOSDocumentsVisual Studio 2010ProjectssavesaveInfo.mdf;Integrated Security=True;User Instance=True") con.Open() 'query the database where Details stands to be the name of the TABLE' sqlstr = "select * from Details" da = New SqlDataAdapter(sqlstr, con) da.Fill(ds, "Details") 'now you can laod data into the combobox' With ComboBox1 .DataSource = ds.Tables("details") .DisplayMember = "ID" '.ValueMember = "CourseCode" ' .SelectedIndex = 0 End With con.Close() |

Leave a comment