Information générale
Catégorie:
Visual FoxPro et .NET
Titre:
Using OleDbParameters and FOXPRO MEMO Fields
Versions des environnements
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement