>I'm having difficulty adding more than 255 characters to a foxpro memo field via asp.net. Any suggestions on how I can solve this?
>The allheader field is the one that blows up. If I change the .Substring(0,256) to .Substring(0,255) all is well again. I've tried on different headers looking for odd characters but I keep getting the same problem at 256 characters. I would really like to be able to add the entire header to the memo field.
>
>Here's the code I'm using:
>
>void logWebPhoneAccess()
>{
> OleDbConnection dbConn = new OleDbConnection(ConfigurationSettings.AppSettings["slaveConn"]);
> dbConn.Open();
> string sql = "";
>
> sql = "INSERT INTO Phonelog (ipaddress,client_id,pixels,wap_profile,user_agent,allheader) "+
> "VALUES ('"+ Request.ServerVariables["HTTP_CLIENT_IP"] +
> "','"+ Request.ServerVariables["HTTP_CLIENTID"]+
> "','"+ Request.ServerVariables["HTTP_UA_PIXELS"]+
> "','"+ Request.ServerVariables["HTTP_X_WAP_PROFILE"]+
> "','"+ Request.ServerVariables["HTTP_USER_AGENT"]+
> "','"+ removeQuotes(Request.ServerVariables["ALL_HTTP"]).Substring(0,256) +"')";
>
> Label1.Text = removeQuotes(Request.ServerVariables["ALL_HTTP"]);
> OleDbCommand cmd = new OleDbCommand(sql, dbConn);
> cmd.ExecuteNonQuery();
> dbConn.Close();
>}
>
>string removeQuotes(string s1)
>{
> return s1.Replace("\"","").Replace("&"," &").Replace("/","").Replace("\n","").Replace("\t","").Replace(";","");
>}
Tim,
Try creating an OleDbCommand and adding parameters to it instead. ie: I'm pasting a memo content here and it was inserted with the sample code - manually removed intendations here:)
string strCon = "Provider=VFPOLEDB;Data source= d:\\cetin\\ddrive\\temp\\Testdata.dbc";
string strSQL = "insert into employee (emp_id,first_name,last_name,notes) values (?,?,?,?)";
OleDbConnection cn = new OleDbConnection(strCon) ;
cn.Open();
OleDbCommand cmdInit = new OleDbCommand("set null off",cn);
cmdInit.ExecuteNonQuery();
OleDbCommand cmd = new OleDbCommand(strSQL,cn);
OleDbParameter emp_id = cmd.Parameters.Add("emp_id",OleDbType.Char);
OleDbParameter first_Name = cmd.Parameters.Add("first_Name",OleDbType.Char);
OleDbParameter last_Name = cmd.Parameters.Add("last_Name",OleDbType.Char);
OleDbParameter notes = cmd.Parameters.Add("notes", OleDbType.Char);
emp_id.Value = txtEmpId.Text;
first_Name.Value = txtFirst.Text;
last_Name.Value = txtLast.Text;
cmd.ExecuteNonQuery();
Cetin