使用access 2010表在vs210中过滤 [英] Filter in vs210 using access 2010 table
问题描述
我做了以下内容并且没有显示任何错误。但是,在调试时它不会过滤陆地领主ID。我已将Access表链接到visual studio 2010 ultimate。我还使用了以下youtube链接:
http://www.youtube.com/watch? v = 4H2g8H0bqEg [ ^ ]
(Stuck on part(11:54))
I have made the following and It shows no errors. However, upon debugging it does not filter the land lord ID. I have linked an Access table to visual studio 2010 ultimate. I also used this following youtube link:
http://www.youtube.com/watch?v=4H2g8H0bqEg[^]
(Stuck on part (11:54))
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
OleDbDataAdapter2.Fill(DataSet11)
End Sub
Private Sub lstLID_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles lstLID.SelectedIndexChanged
Dim landlord_ID, SQLString As String
Dim dtFlats As New DataTable()
Dim dbDataAdapter As OleDbDataAdapter
Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = Database.accdb"
landlord_ID = lstLID.Text
SQLString = "SELECT = FROM Flats WHERE ID = " & landlord_ID & ""
dbDataAdapter = New OleDbDataAdapter(SQLString, ConnectString)
dbDataAdapter.Fill(dtFlats)
grdflats.DataSource = dtFlats
End Sub
End Class
推荐答案
要正确连接到MS Access数据库2007及更高版本,请使用此连接字符串: http://connectionstrings.com/access-2007 [ ^ 一>]。过滤器应该开始工作;)
Suhail19,
太多了要解释的事情......但是,你需要做的是:
1)创建 OleDbConnection [ ^ ],
2)使用方法打开() [ ^ ]方法,
3)创建 OleDbCommand [ ^ ]
4)设置 CommandType [ ^ ], CommandText [ ^ ]属性,
5)创建 OleDbDataReader [ ^ ]并致电 ExecuteReader() [ ^ ]方法。
6)创建DataTable [ ^ ]和加载() [ ^ ]数据。
7)将数据与组件绑定以显示数据,例如:
To proper connect to MS Access database 2007 and higher, use this connection string: http://connectionstrings.com/access-2007[^]. Than filter should start working ;)
Suhail19,
There is too many things to explain... but, what you need to do is:
1) Create OleDbConnection[^],
2) Open it using method Open()[^] method,
3) Create OleDbCommand[^]
4) Set CommandType[^], CommandText[^] properties,
5) Create OleDbDataReader[^] and call ExecuteReader()[^] method.
6) Create DataTable[^] and Load()[^] data from OleDbDataReader.
7) Bind data with your component to display data, for example:
DataGridView.DataSource = DataTableObject
请按照以下链接:
演练:编辑Access数据库wi ADO.NET [ ^ ]
ADO.NET Overiview [ ^ ]
ADO.NET(核心数据访问) [ ^ ]
http://vbdotnettutorials.ktsinfotech.com/DataBaseProgramming.aspx [ ^ ]
Please, follow below links:
Walkthrough: Editing an Access Database with ADO.NET[^]
ADO.NET Overiview[^]
ADO.NET (core data access)[^]
http://vbdotnettutorials.ktsinfotech.com/DataBaseProgramming.aspx[^]
这篇关于使用access 2010表在vs210中过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!