I'm using ADO.NET 2.0 driver from Embracadero and trying to connect to remote Interbase base (http://cc.embarcadero.com/item/25497). I'm trying to do insert query to my database, but when I do insert query it throws "Object reference not set to an instance of an object." Does anybody have the same problem?
I have:
public DbConnection GetConnection()
{
DbConnection con = new TAdoDbxConnection();
con.ConnectionString = _connectionString;
return con;
}
and then I do:
using (var conn = GetConnection())
{
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = query;
var param = cmd.CreateParameter();// <---- here exception is thrown
NazwaChannel.ParameterName = "@param";
NazwaChannel.Value = 1000;
NazwaChannel.DbType = DbType.Int32;
cmd.Parameters.Add(param);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
query is like "Insert into Table (tableID, columnname) values (GEN_ID(GenaratorName, 1), @param)".