VB.NET上面的问题(在调用“Fill”前,SelectCommand 属性尚未初始化)

DimOleDbCommand1AsSystem.Data.OleDb.OleDbCommandDimoledbdataadapterAsSystem.Data.OleD... Dim OleDbCommand1 As System.Data.OleDb.OleDbCommand
Dim oledbdataadapter As System.Data.OleDb.OleDbDataAdapter
Dim dataadapter As System.Data.OleDb.OleDbDataAdapter

OleDbConnection1.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=d:\My Documents\Visual Studio 2005\Projects\WindowsApplication4\WindowsApplication4\db.mdb" 'ACCESS链接字符串

OleDbCommand1 = New System.Data.OleDb.OleDbCommand

OleDbConnection1.Open() '打开数据库

OleDbCommand1.CommandText = "Select * from 联系人" '要执行的SQL语句

oledbdataadapter = New OleDb.OleDbDataAdapter(OleDbConnection1.ConnectionString, OleDbConnection1) '创建DataAdapter数据适配器实例

Dim customerOrders As DataSet = New DataSet("CustomerOrders") '创建DataSet实例()

dataadapter = New System.Data.OleDb.OleDbDataAdapter

dataadapter.Fill(New DataSet, "联系人") '使用DataAdapter的Fill方法(填充),调用SELECT命令

OleDbConnection1.Close() '关闭数据库

为什么我在运行的时候出现 在调用“Fill”前,SelectCommand 属性尚未初始化?怎么修改?
展开
 我来答
百度网友2e7112b2a
2006-08-24 · TA获得超过106个赞
知道答主
回答量:140
采纳率:0%
帮助的人:0
展开全部
Dim OleDbCommand1 As System.Data.OleDb.OleDbCommand
Dim oledbdataadapter As System.Data.OleDb.OleDbDataAdapter
Dim dataadapter As System.Data.OleDb.OleDbDataAdapter

OleDbConnection1.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=d:\My Documents\Visual Studio 2005\Projects\WindowsApplication4\WindowsApplication4\db.mdb"

OleDbCommand1 = New System.Data.OleDb.OleDbCommand

OleDbCommand1.CommandText = "Select * from 联系人"

OleDbCommand1.Connection=OleDbConnection1

OleDbConnection1.Open()

dataadapter = New System.Data.OleDb.OleDbDataAdapter

dataadapter.SelectCommand = OleDbCommand1

Dim customerOrders As DataSet = New DataSet("CustomerOrders")

dataadapter.Fill(customerOrders , "联系人")

OleDbConnection1.Close()
平晴虹EN
2006-08-24 · 超过11用户采纳过TA的回答
知道答主
回答量:52
采纳率:0%
帮助的人:0
展开全部
OleDbCommand1.connection=OleDbConnection1
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式