General information
Category:
Visual FoxPro and .NET
Title:
Using OleDbParameters and FOXPRO MEMO Fields
Environment versions
Network:
Windows 2000 Server
Language C#
Database FoxPro 6.0
Problem to insert data in table, specificlly MEMO fields with a value over 254 charaters in length
We have been told by "experts" to us a parameter to insert a value into a memo field
we can find no example and we are unable even to get simple parameters to work
I have the following c# Code:
string sSqlStmt = "";
sSqlStmt += " INSERT INTO iwebillsettings ( ";
sSqlStmt += " iwb_pk ";
sSqlStmt += " ) VALUES ( ";
sSqlStmt += " ? ";
sSqlStmt += " )";
decimal dClientId = 123;
if(SqlConn.State == ConnectionState.Closed)
{
SqlConn.Open();
}
bGoodRecord = false;
try
{
SqlCmd = new OleDbCommand(sSqlStmt, SqlConn );
SqlCmd.Parameters.Add(new OleDbParameter("@pk", OleDbType.Numeric));
SqlCmd.Parameters["@pk"].Precision = 11;
SqlCmd.Parameters["@pk"].Scale = 0;
SqlCmd.Parameters["@pk"].Value = dClientId;
SqlCmd.Prepare();
int iRowCheck = SqlCmd.ExecuteNonQuery();
if (iRowCheck > 0)
{
bGoodRecord = true;
}
else
{
bGoodRecord = false;
}
}
catch(Exception ex)
{
string sOutName = "";
sOutName += "Err Source: " + ex.Source + "
\n";
sOutName += "Message: " + ex.Message + "\n";
bGoodRecord = false;
}
finally
{
if(SqlConn.State == ConnectionState.Open)
{
SqlConn.Close();
}
}
I continue to get the following error
{"Object reference not set to an instance of an object." }
Important notes .. the database is fine.. if I run a text insert statement I have no issues
IF we could get at least the ID field to work, it would be a start but what I would really like is a working example of code that inserts a value into a MEMO fields . and the value being more than 255 char in length
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only