我正在從mysql數據庫表中讀取數據。 我已填充下拉與相關slections,我希望表單其餘一旦我選擇車牌號碼加載數據...在下拉列表中選擇後在asp.net(VB.net)中加載數據
的數據在同一個表...
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
我正在使用ablove類來驗證數據...
已經有一個與此連接關聯的打開的DataReader,它必須先關閉。
我讀/由我寫了工程100%
否;那不能100%工作。你有一個SQL注入漏洞。 – SLaks 2012-03-12 18:03:13