Subject Re: [ib-support] FB.Net Provider Error
Author Carlos Guzmán Álvarez
Hello:

> I'm using FB.Net provider to connect to a database. I can connect to
> the database, but when I try to execute a query I get this error
>
> "Object reference not set to an instance of an object".
>
> I'm just trying simple updates to a table. (Same query that is in Help
> on FbConnection)
>
> What am I doing wrong?

The sample is wrong, please test with this:


public void InsertRow(string myConnectionString)
{
// If the connection string is null, use a default.
if(myConnectionString == "")
{
myConnectionString = "Database=C:\\PROGRAM
FILES\\FIREBIRD\\EXAMPLES\\EMPLOYEE.GDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost";
}

FbConnection myConn = new FbConnection(myConnectionString);
myConn.Open();
FbTransaction myTxn = myConn.BeginTransaction();
string myInsertQuery = "INSERT INTO PROJECT(proj_id,
proj_name, product) Values('FBNP', '.Net Provider', 'N/A')";
FbCommand myFbCommand = new FbCommand(myInsertQuery, myConn,
myTxn);
myFbCommand.ExecuteNonQuery();
myConn.Close();
}



Best regards
Carlos Guzmán Álvarez
vigo-Spain