谁能告诉我这个代码为什么不能在datagrid里面显示结果呢

我是用dropdownlist来选择要查询的信息的,button1是查看按钮,选择dropdownlist里面的字段信息然后点按钮,把想要查询信息列出在datagrid里面。。可是我点了。。没有显示出来。。哪位能帮我解决下。偶是新手来的。一个简单问题。。。还请多指教。。

    Private Sub List1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles List1.Load
        Dim strmycon1 As String = ConfigurationSettings.AppSettings("sqlconnection")
        Dim SqlConnection1 As New SqlClient.SqlConnection(strmycon1)
        Dim dReader As System.Data.SqlClient.SqlDataReader
        SqlConnection1.Open()
        Dim SqlCommand1 As New SqlClient.SqlCommand
        SqlCommand1.Connection = SqlConnection1
        SqlCommand1.CommandText = "Select ele_cou_name,ele_cou_id from select_information"
        dReader = SqlCommand1.ExecuteReader()
        List1.DataSource = dReader
        List1.DataTextField = "ele_cou_name"
        List1.DataValueField = "ele_cou_id"
        List1.DataBind()
        dReader.Close()
        SqlConnection1.Close()
        Label1.Text = List1.SelectedValue
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim conn As String = ConfigurationSettings.AppSettings("sqlconnection")
    Dim sql As String = "Select * from select_information where ele_cou_id='%" & List1.SelectedValue & "%'"
    Dim comm As SqlDataAdapter = New SqlDataAdapter(sql, conn)
    Dim ds As DataSet
    ds = New DataSet
    comm.Fill(ds, "stu_base")
    DataGrid2.DataSource = ds.Tables("stu_base"). defaultview

DataGrid2.DataBind()

    End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值