数据筛选与显示 (VB 2005+ACCESS)
就是想从combo里确定房间类型 然后从access里把选择的一列显示出来,代码有什么问题呢?有错误帮忙指一下哦,有好的办法请指教:)谢谢啦!刚开始学难免很菜呵呵
Dim MyConn As New OleDb.OleDbConnection
Dim MyDataAdapter As New OleDb.OleDbDataAdapter
Dim MySelectCommand As New OleDb.OleDbCommand
Dim MyInsertCommand As New OleDb.OleDbCommand
Dim MyUpdateCommand As New OleDb.OleDbCommand
Dim MyDeleteCommand As New OleDb.OleDbCommand
Dim MyDataSet = New DataSet("MyNewDataSet")
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../../authority.mdb;Jet OLEDB:Database Password=12345"
MyConn.Close()
MyConn.Open()
If Combo_Class.SelectedItem = "Presidential(suites)" Then
MySelectCommand.CommandText = "Select * RoomNo from RoomDetails WHERE Classification='Presidential(suites)'"
ElseIf Combo_Class.SelectedItem = "Sea View Rooms" Then
MySelectCommand.CommandText = "Select * RoomNo from RoomDetails WHERE Classification='Sea View Rooms'"
ElseIf Combo_Class.SelectedItem = "Twin(Rooms)" Then
MySelectCommand.CommandText = "Select * RoomNo from RoomDetails WHERE Classification='Twin(Rooms)'"
End If
MySelectCommand.Connection = MyConn
MyDataAdapter.SelectCommand = MySelectCommand
DataGridView1.CaptionText = "RoomDetails"
DataGridView1.DataSource = MyDataSet
MyDataAdapter.Fill(MyDataSet)
--------------------编程问答-------------------- MyConn.Close()
-----------------------------
上面的代码是做什么哪?
难道是为了断开上一次的连接? --------------------编程问答-------------------- 建议填充DATASET后再绑定到DATAGRIDVIEW --------------------编程问答-------------------- 直接在2005里用数据绑定空间不行吗?? --------------------编程问答-------------------- 具体怎么改呢?请明示:)
补充:.NET技术 , VB.NET