|
-
Feb 26th, 2009, 12:53 AM
#1
Thread Starter
Member
[RESOLVED] [2008] Combo box read write MySQL
for starters not sure if this is the right place for the post considering that it includes MySQL and VB, its here.
I'm trying to load data from one table into a combo box as the data you can select, this i have been able to do "tbl_Wind" using "WindDirID" and "WindDir"
also, I am trying to select (if it exists) a value from "tbl_date" "WindDirID" to select a value from the existing data in the combo box loaded from "tbl_wind"
and finally, I want to be able to change the value in the "tbl_Date" depending on if a value is selected in the combo box.
when a new record is created in tbl_date it uses default values, so there is always something in the field
below is about how far i got, and its the only part that works (extracted and edited of course to exclude the other queries)
Code:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myCommandWindDir As New MySqlCommand
Dim myAdapterWindDir As New MySqlDataAdapter
Dim myDataWindDir As New DataTable
Dim SQLWindDir As String
SQLWindDir = "(select * " _
& "FROM" & " " & My.Settings.Surfcom & ".tbl_Wind x " _
& "order by x.WindDirid)"
conn.ConnectionString = myConnString
Try
conn.Open()
Try
myCommandWindDir.Connection = conn
myCommandWindDir.CommandText = SQLWindDir
myAdapterWindDir.SelectCommand = myCommandWindDir
myAdapterWindDir.Fill(myDataWindDir)
cboWindDir.DataSource = myDataWindDir
cboWindDir.DisplayMember = "WindDirection"
cboWindDir.ValueMember = "WindDirID"
Catch myerror As MySqlException
MsgBox("There was an error reading from the database: " & myerror.Message)
End Try
Catch myerror As MySqlException
MessageBox.Show("Error connecting to the database: " & myerror.Message)
Finally
If conn.State <> ConnectionState.Closed Then conn.Close()
End Try
End Sub
I hope that i am clear on what i am after, reading this, im not so sure
thanks
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
|