VB2005 + ACCESS
哪个熟悉WINFORM的高手能指教一下,用VB2005操纵ACCESS数据库,并可以更新,添加,删改数据的例子?最好是有代码提供参考!谢谢了...--------------------编程问答-------------------- 怎么在这个论坛都没有人理的啦?在EXCELHOME里面人气好多了. --------------------编程问答-------------------- 主要是这个问题,已经回叙多遍了,你搜一下,有妇多的 --------------------编程问答-------------------- 通过ADO.NET访问数据库集体技术细节 还是参考相应的书籍吧。
象你这样的零分贴 有谁会谁回呢??? --------------------编程问答-------------------- 找本书来看吧,有好多例子啊! --------------------编程问答-------------------- 基础知识,请咨询百度\GOOGLE等搜索引擎 --------------------编程问答-------------------- bs楼主一下! --------------------编程问答-------------------- 不为分数,只想让大家在这里讨论一下,哪种方法最好,最经济! --------------------编程问答-------------------- Try
Dim s1 As String
Dim c As OleDb.OleDbConnection
s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "这里是路径的字符串"
s1 = s1 & " ;jet oledb:database password=数据库密码"
C = New OleDb.OleDbConnection(s1)
Try
C.Open()
Catch ex As Exception
MsgBox("数据库连接失败,程序即将退出! " & vbCrLf & "请连接好后重试。", MsgBoxStyle.Critical, "Closing")
Exit Sub
End Try
Catch ex As Exception
C = Nothing
End Try
即然没有人告诉我,那我就在这里告诉那些还不知道怎么做的人,数据库的连接方法. --------------------编程问答-------------------- Public Function loadcnn() As DataSet
Try
Dim oldcnnstr As New OleDb.OleDbConnectionStringBuilder
oldcnnstr.DataSource = "D:\data\barlitong.xls"
oldcnnstr.Provider = "Microsoft.Jet.OLEDB.4.0"
oldcnnstr.Add("Extended properties", "Excel 8.0")
Using oldcnn As New OleDbConnection(oldcnnstr.ConnectionString)
oldcnn.Open()
Dim oldcmd As New OleDbCommand("select * from [bar$]", oldcnn)
Dim ds As New DataSet
Dim oldread As OleDbDataReader = oldcmd.ExecuteReader()
ds.Load(oldread, LoadOption.OverwriteChanges, New String() {"bar"})
Return ds
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Warnning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
End Try
Return Nothing
End Function
--------------------编程问答-------------------- Public Function loadcnn() As DataSet
Try
Dim oldcnnstr As New OleDb.OleDbConnectionStringBuilder
oldcnnstr.DataSource = "D:\data\barlitong.MDB"
oldcnnstr.Provider = "Microsoft.Jet.OLEDB.4.0"
Using oldcnn As New OleDbConnection(oldcnnstr.ConnectionString)
oldcnn.Open()
Dim oldcmd As New OleDbCommand("select * from [bar$]", oldcnn)
Dim ds As New DataSet
Dim oldread As OleDbDataReader = oldcmd.ExecuteReader()
ds.Load(oldread, LoadOption.OverwriteChanges, New String() {"bar"})
Return ds
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Warnning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
End Try
Return Nothing
End Function
聯接Access 數據庫
--------------------编程问答-------------------- Public Function loadcnn() As DataSet
Try
Dim oldcnnstr As New OleDb.OleDbConnectionStringBuilder
oldcnnstr.DataSource = "D:\data\barlitong.MDB"
oldcnnstr.Provider = "Microsoft.Jet.OLEDB.4.0"
Using oldcnn As New OleDbConnection(oldcnnstr.ConnectionString)
oldcnn.Open()
Dim oldcmd As New OleDbCommand("select * from [bar$]", oldcnn)
Dim ds As New DataSet
Dim oldread As OleDbDataReader = oldcmd.ExecuteReader()
ds.Load(oldread, LoadOption.OverwriteChanges, New String() {"bar"})
Return ds
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Warnning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
End Try
Return Nothing
End Function --------------------编程问答-------------------- 不是因为你是零分数.只是你的问题太空泛了.无从回答起,只能告诉你用ADO.NET或是ORM思想.然后你自己去参考资料. --------------------编程问答-------------------- 你搜一下,一大堆这样的例子 --------------------编程问答-------------------- 你直接放上来让大家看看不是更好? --------------------编程问答-------------------- 我也在找这样的例子,vb2005的DataGridView和Access的应用.找的很辛苦啊.呵呵. --------------------编程问答-------------------- ..............就说1句,有OLEDB连接,之后LZ自己想办法,其实我也想BS下的,算了,谁还不是被BS过来的捏. --------------------编程问答-------------------- 看看ADO.NET的书...很简单滴...
补充:.NET技术 , VB.NET