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 属性尚未初始化?怎么修改? 展开
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 属性尚未初始化?怎么修改? 展开
展开全部
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()
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()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询