注册 登录
编程论坛 VB.NET论坛

新手菜鸟,求助!急!急!

安一心 发布于 2012-12-15 20:17, 549 次点击
求一个查询代码。
就是想让查询结果显示在一个文本框里 代码怎么写?
2 回复
#2
角角鱼2013-01-14 09:30
回复 楼主 安一心
Try
                conn.Open()
                Dim cmd_sel5 As New OleDbCommand(sel_str5, conn)
                Dim ds5 As New OleDbDataAdapter(cmd_sel5)
                Dim da5 As New DataSet()
                ds5.Fill(da5)
                TextBox_ownteam_shili.Text = da5.Tables(0).Rows(0)(0).ToString()
                conn.Close()
                cmd_sel5.Dispose()
                cmd_sel5 = Nothing
                ds5.Dispose()
                ds5 = Nothing
                da5.Dispose()
                da5 = Nothing
            Catch ex As Exception
                MessageBox.Show(ex.Message.ToString())
            End Try
#3
角角鱼2013-01-14 09:32
回复 楼主 安一心
Dim sel_str5 As String
            sel_str5 = "select shili from football_shili where county ='" & ComboBox_county.Text & "' and season = '" & TextBox_saiji.Text & "' and teamname='" & TextBox_ownteam.Text & "'"
            Try
                conn.Open()
                Dim cmd_sel5 As New OleDbCommand(sel_str5, conn)
                Dim ds5 As New OleDbDataAdapter(cmd_sel5)
                Dim da5 As New DataSet()
                ds5.Fill(da5)
                TextBox_ownteam_shili.Text = da5.Tables(0).Rows(0)(0).ToString()
                conn.Close()
                cmd_sel5.Dispose()
                cmd_sel5 = Nothing
                ds5.Dispose()
                ds5 = Nothing
                da5.Dispose()
                da5 = Nothing
            Catch ex As Exception
                MessageBox.Show(ex.Message.ToString())
            End Try
        End If
1