B
Bill Simakis
Hello,
I am working on a data access component which access a foxpro db using the
OleDb provider for foxpro. In my component I am using a OleDbDataAdapter to
fill a dataset which is return to user of my component. This works fine,
however when I try and use the same OleDbDataAdapter to update the DB with
the information contained in a DataSet I get an NullObjectRefenence
exception.
I have used the DataAdpater configuration wizard but it encounters an error
with my select statement due to the parameter, hence does not generate an
insert, update or delete command.
Thanks in advance for the help.
Bill
Dev environment: VS .NET 2003
OleDbProvider : included with Visual FoxPro 7.0
My Database schema is as follows:
Table1
--------------
irow -> Primary key (Default value = Max value + 1)
name -> string
value -> string
owner -> integer (Foreign key to Table 2)
host -> string
Table2
------------
id -> integer Primary Key
name -> string
description -> string
My Select statement:
SELECT name, value, owner, host FROM table1,table2 WHERE table1.owner =
table2.id AND table2.name = ?
My insert statement is below:
INSERT INTO table1 (name, value, owner, host) VALUES (?,?,?,?)
My Update Statement:
UPDATE table1 SET name = ?, value = ?, host = ? WHERE irow = ?
My delete statement:
DELETE FROM table1 WHERE irow =?
The following is the code I use to get the DataSet:
dataAdapter.SelectCommand.Parameters["OwnerName"].Value = OwnerName;
if ( dataAdapter.Fill( dataset ) == 0 )
{
dataset = null;
}
And to update the DB,
ParameterSetAdapter.Update( dataset );
I am working on a data access component which access a foxpro db using the
OleDb provider for foxpro. In my component I am using a OleDbDataAdapter to
fill a dataset which is return to user of my component. This works fine,
however when I try and use the same OleDbDataAdapter to update the DB with
the information contained in a DataSet I get an NullObjectRefenence
exception.
I have used the DataAdpater configuration wizard but it encounters an error
with my select statement due to the parameter, hence does not generate an
insert, update or delete command.
Thanks in advance for the help.
Bill
Dev environment: VS .NET 2003
OleDbProvider : included with Visual FoxPro 7.0
My Database schema is as follows:
Table1
--------------
irow -> Primary key (Default value = Max value + 1)
name -> string
value -> string
owner -> integer (Foreign key to Table 2)
host -> string
Table2
------------
id -> integer Primary Key
name -> string
description -> string
My Select statement:
SELECT name, value, owner, host FROM table1,table2 WHERE table1.owner =
table2.id AND table2.name = ?
My insert statement is below:
INSERT INTO table1 (name, value, owner, host) VALUES (?,?,?,?)
My Update Statement:
UPDATE table1 SET name = ?, value = ?, host = ? WHERE irow = ?
My delete statement:
DELETE FROM table1 WHERE irow =?
The following is the code I use to get the DataSet:
dataAdapter.SelectCommand.Parameters["OwnerName"].Value = OwnerName;
if ( dataAdapter.Fill( dataset ) == 0 )
{
dataset = null;
}
And to update the DB,
ParameterSetAdapter.Update( dataset );