SQUASHJUNKIE
IS-IT--Management
Hi,
I'm a bit of a beginer to VB.net and have struggled throught the last couple of days to produce a simple form.
However I want the form to show data based on a selection from a combo box, but I keep getting an error. I beleive the problem to be in my sql statement, but at the moment I cant see the wood for the trees! Can anyone see any problems with the code below?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Load the Combo Box
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11, "qry01_artran_data")
Me.Btnupdate.Enabled = False
End Sub
Private Sub cbodocno_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbodocno.SelectedIndexChanged
'load the dataconnection for the form
Dim conn As OleDb.OleDbConnection = OleDbConnection1
Dim selectstring As String
Dim cmd As OleDb.OleDbCommand
Dim reader As OleDb.OleDbDataReader
Try
conn.Open()
selectstring = "select DOCNO, customer_name, DOCDATE, TERMSDESC, no_months, date1, date2 from QRY01_ARTRAN_DATA WHERE sysdocid = '" & cbodocno.SelectedValue & "'"
cmd = New OleDb.OleDbCommand(selectstring, conn)
reader = cmd.ExecuteReader()
While (reader.Read())
LBLCUSTNAME.Text = reader(1)
LBLDOCDATE.Text = reader(2)
LBLTERMSDESC.Text = reader(3)
lblmonths.Text = reader(4)
LBLDAY1.Text = reader(5)
LBLDAY2.Text = reader(6)
Me.Btnupdate.Enabled = True
End While
reader.Close()
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "access database", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
I'm a bit of a beginer to VB.net and have struggled throught the last couple of days to produce a simple form.
However I want the form to show data based on a selection from a combo box, but I keep getting an error. I beleive the problem to be in my sql statement, but at the moment I cant see the wood for the trees! Can anyone see any problems with the code below?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Load the Combo Box
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11, "qry01_artran_data")
Me.Btnupdate.Enabled = False
End Sub
Private Sub cbodocno_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbodocno.SelectedIndexChanged
'load the dataconnection for the form
Dim conn As OleDb.OleDbConnection = OleDbConnection1
Dim selectstring As String
Dim cmd As OleDb.OleDbCommand
Dim reader As OleDb.OleDbDataReader
Try
conn.Open()
selectstring = "select DOCNO, customer_name, DOCDATE, TERMSDESC, no_months, date1, date2 from QRY01_ARTRAN_DATA WHERE sysdocid = '" & cbodocno.SelectedValue & "'"
cmd = New OleDb.OleDbCommand(selectstring, conn)
reader = cmd.ExecuteReader()
While (reader.Read())
LBLCUSTNAME.Text = reader(1)
LBLDOCDATE.Text = reader(2)
LBLTERMSDESC.Text = reader(3)
lblmonths.Text = reader(4)
LBLDAY1.Text = reader(5)
LBLDAY2.Text = reader(6)
Me.Btnupdate.Enabled = True
End While
reader.Close()
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "access database", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class