Subject | Re: [ib-support] FB.Net Provider Error |
---|---|
Author | Carlos Guzmán Álvarez |
Post date | 2002-11-18T10:37:08Z |
Hello:
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
> I'm using FB.Net provider to connect to a database. I can connect toThe sample is wrong, please test with this:
> 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?
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