i am reading data from a mysql database table.
I have populated a dropdown with the relevant slections, i want the rest of the form to load data once i select the plate number …
the data is in the same table …
Sub getdata()
Dim ds_vehicles As DataSet = GetDataSet("select * from tbl_vehicles where fld_ownerSNO='" & Session("logID") & "'", "tbl_v")
DTPageData = ds_vehicles.Tables("tbl_v")
ddl_plate.DataSource = ds_vehicles.Tables("tbl_v")
ddl_plate.DataTextField = "fld_plate"
ddl_plate.DataValueField = "fld_vno"
ddl_plate.DataBind()
End Sub
Protected Sub ddl_plate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_plate.SelectedIndexChanged
'Dim ds_vehicles2 As DataSet = GetDataSet("select * from tbl_vehicles where fld_ownerSNO='" & Session("logID") & "' and fld_vin=" & sel_vno & "", "tbl_v2")
'lbl_vin.Text = ds_vehicles2.Tables("tbl_v2").Rows(0).Item("fld_vin")
End Sub
Public Shared Function GetDataSet(ByVal cmdStr As String, ByVal tblName As String) As Data.DataSet
OpenRemoteDataConnection()
GetDataSet = New Data.DataSet
Dim sqlcmd As New MySqlCommand(cmdStr, RConn)
Dim sqladp As New MySqlDataAdapter
sqladp.SelectCommand = sqlcmd
sqladp.Fill(GetDataSet, tblName)
CloseRemoteConnection()
End Function
Public Shared Sub OpenRemoteDataConnection()
If RConn.State = Data.ConnectionState.Open Or RConn.State = Data.ConnectionState.Connecting Then RConn.Close()
RConn = New MySqlConnection(dataFilePath)
RConn.Open()
End Sub
Public Shared Sub CloseRemoteConnection()
If RConn.State = Data.ConnectionState.Open Then RConn.Close()
End Sub
i am using the ablove class to conent to the datasbe…
There is already an open DataReader associated with this Connection which must be closed first.
i am reading/writing to dbase by a class that i have written that works 100%
As the error clearly states, you’re trying to do two things with the same connection at the same time.
Either don’t share connections or close your data readers, depending on what the problem with your database class is.