Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using OleDbParameters and FOXPRO MEMO Fields
Message
From
27/06/2005 17:03:41
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Title:
Using OleDbParameters and FOXPRO MEMO Fields
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01026872
Message ID:
01026872
Views:
100
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
Map
View

Click here to load this message in the networking platform