asp.net
  • vb.net
  • 2012-03-12 49 views 0 likes 
    0

    我正在從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%

    +0

    否;那不能100%工作。你有一個SQL注入漏洞。 – SLaks 2012-03-12 18:03:13

    回答

    1

    由於錯誤清楚地類寫作到dBASE,你正在做兩件事情在同一時間同一個連接。

    要麼不共享連接或關閉數據讀取器,這取決於數據庫類的問題。

    +0

    我在類中使用函數GetDataSet來打開和關閉dbase,因此當選擇形式下拉時,數據庫不能確定。 – abbyyUser 2012-03-12 18:25:13

    +0

    _不使用共享連接_。那是你的問題。 – SLaks 2012-03-12 18:32:29

    +0

    我正在關閉該連接.. – abbyyUser 2012-03-12 18:42:50

    相關問題