Asp.net多表访问vb.net

时间:2017-07-14 06:32:28

标签: asp.net vb.net

和美好的一天..

我在vb.net中有一个asp.net的代码并且可以正常工作一个表但是我需要添加多个表(master和dr)来编码数据是两个表的总和但它的不同。任何人都可以帮助我......谢谢所有人的进步

Private Sub getData(ByVal user As String)
        Dim dt As New DataTable()
        Dim connectionString As String
        Dim connection As OleDbConnection
        connectionString = ConfigurationManager.ConnectionStrings("Data_For_netConnectionString").ToString
        connection = New OleDbConnection(connectionString)
        connection.Open()
        Dim sqlCmd As New OleDbCommand("SELECT * from master WHERE UserID = @user", connection)
        sqlCmd.CommandText = _
            "SELECT name, manistry, university, send, card FROM master "
        Dim sqlDa As New OleDbDataAdapter(sqlCmd)
        sqlCmd.Parameters.AddWithValue("@user", user)
        sqlDa.Fill(dt)
        If dt.Rows.Count > 0 Then
            TextBox1.Text = dt.Rows(0)("manistry").ToString
            TextBox2.Text = dt.Rows(0)("university").ToString
            TextBox4.Text = dt.Rows(0)("send").ToString
            TextBox21.Text = dt.Rows(0)("card").ToString
            name.Text = dt.Rows(0)("name").ToString
        End If
        connection.Close()
    End Sub

0 个答案:

没有答案