我是用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