[VB.NET]Fill:SelectCommand.Connection property has not been initialized

前端之家收集整理的这篇文章主要介绍了[VB.NET]Fill:SelectCommand.Connection property has not been initialized前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Fill:SelectCommand.Connection property has not been initialized Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand Connection.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/homeautosys.mdb Connection.Open() DataTab_LightOff.Clear() Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter dataAdapter.SelectCommand = dbCommand Dim DataAdapter_LighOff As System.Data.DataSet = New System.Data.DataSet command_LightOff = update [Lights] set [Off_On]= Off Where ( [Lights].[Room_Name]= Bedroom One ) DataAdapter_LightOff = New Data.OleDb.OleDbDataAdapter(command_LightOff,Connection) dataAdapter.Fill(DataTab_LightOff) 这是源代码,编译的时候出现错误:Fill:SelectCommand.Connection property has not been initialized 这是什么原因?该怎么改? 是在移动页面上做的 目的是实现点COMMAND的控件,然后数据库中中BEDROOM ONE的那行的OFF_ON列对应的值变为OFF 如果上面的方法不对,最完写完整的另外的代码! __________________________________________________________________________ dbCommand.CommandText = select *.... ; 需要指定。 __________________________________________________________________________ Connection.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/homeautosys.mdb Connection.Open() Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand( update [Lights] set [Off_On]= Off Where ( [Lights].[Room_Name]= Bedroom One ) ) dbCommand.Connection=Connection dbCommand.ExecuteNonQuery __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263419.html

猜你在找的VB相关文章