2009年12月28日 星期一

[vb.net] dataset, oledbadapter and oledbcommandbuilder

用在Access的Dataadapter 可正常寫入

Dim conntion_access As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database.mdb;Persist Security Info=True;Jet OLEDB:Database Password="
Dim oleconn As OleDbConnection
Dim oleconn As OleDbConnection
dim oleda As OleDbDataAdapter
Dim olecb As OleDbCommandBuilder
Dim oleds As New DataSet
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
oleconn = New OleDbConnection(conntion_access)
Try
oleconn.Open()
oleda = New OleDbDataAdapter("SELECT * FROM TABLE", oleconn)
oleda.MissingSchemaAction = MissingSchemaAction.AddWithKey ' if need priKEY
olecb = New OleDbCommandBuilder(oleda)
olecb.QuotePrefix = "[" 'fixed keyword
olecb.QuoteSuffix = "]"
oleda.Fill(oleds, "PC")
oleconn.Close()
catch ex as exception
msgbox("DB Error!!")
end try
End Sub

沒有留言: