N
nick
The code write to a dbf file. However, started from today I always got the
error: "Object reference not set to an instance of an object." And the
StackTrace and code are:
StackTrace " at System.Data.Common.ICommandText.Execute(IntPtr pUnkOuter,
Guid riid, tagDBPARAMS pDBParams, Int32& pcRowsAffected, Object& ppRowset)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at DAL.Camms.DAL.dalWorkOrder.InsertWO_dbf(Boolean Activity, String
WOTYPE, String REF_NO, String PRIORITY, String Unit, String DEPT, String
DEPT_ID, String PAC2, String RQNAME, String RQPHONE, String SHOP, String
ASTO, DateTime WODATE, String OPTR, String LOCATION, String COMM1, String
ROOM, Double ESTHR, String STATUS, String UP, String FLR) in
C:\DAL\WorkOrder.vb:line 146" String
Class DAL
static public function writedbf()
....
Dim dbfConnectionString as String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\dbfs;Extended Properties=dBase IV;User ID=Admin;Password="
Dim InsertCmdStr As String = "Insert Into wolog (WOTYPE, REF_NO, PRIORITY,
Unit, DEPT, DEPT_ID, PAC2, RQNAME, RQPHONE, SHOP, ASTO, WODATE, OPTR,
LOCATION, COMM1, ESTHR, STATUS, UP, ROOM, FLR) values
('D','D700804','5','90','740','1','2BUS','a','a','SEC','','11/10/2004
2:02:27 PM','login','2 BUS ST a ','a ',0,'N','N','a','')"
Dim cmd As New OleDbCommand(InsertCmdStr, New
OleDbConnection(dbfConnectionString))
cmd.Connection.Open()
Try
REF_NO = cmd.ExecuteScalar()
Catch err As Exception
Throw err
Finally
If Not cmd.Connection Is Nothing Then
cmd.Connection.Close()
End If
End Try
error: "Object reference not set to an instance of an object." And the
StackTrace and code are:
StackTrace " at System.Data.Common.ICommandText.Execute(IntPtr pUnkOuter,
Guid riid, tagDBPARAMS pDBParams, Int32& pcRowsAffected, Object& ppRowset)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at DAL.Camms.DAL.dalWorkOrder.InsertWO_dbf(Boolean Activity, String
WOTYPE, String REF_NO, String PRIORITY, String Unit, String DEPT, String
DEPT_ID, String PAC2, String RQNAME, String RQPHONE, String SHOP, String
ASTO, DateTime WODATE, String OPTR, String LOCATION, String COMM1, String
ROOM, Double ESTHR, String STATUS, String UP, String FLR) in
C:\DAL\WorkOrder.vb:line 146" String
Class DAL
static public function writedbf()
....
Dim dbfConnectionString as String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\dbfs;Extended Properties=dBase IV;User ID=Admin;Password="
Dim InsertCmdStr As String = "Insert Into wolog (WOTYPE, REF_NO, PRIORITY,
Unit, DEPT, DEPT_ID, PAC2, RQNAME, RQPHONE, SHOP, ASTO, WODATE, OPTR,
LOCATION, COMM1, ESTHR, STATUS, UP, ROOM, FLR) values
('D','D700804','5','90','740','1','2BUS','a','a','SEC','','11/10/2004
2:02:27 PM','login','2 BUS ST a ','a ',0,'N','N','a','')"
Dim cmd As New OleDbCommand(InsertCmdStr, New
OleDbConnection(dbfConnectionString))
cmd.Connection.Open()
Try
REF_NO = cmd.ExecuteScalar()
Catch err As Exception
Throw err
Finally
If Not cmd.Connection Is Nothing Then
cmd.Connection.Close()
End If
End Try