Hi Schweic,
We can create a OleDb connection to update data to Access. The oledb type of the text type in Access is
OleDbType.VarWChar. This is a code sample:
private string CONNECTION_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;";
private void WriteToAccess()
{
OleDbConnection myConnection = null;
try
{
//Get the rtf text.
string rtf = GetRtf();
string title = "rtf1";
//create the SQL statement to add the rtf data
myConnection = new OleDbConnection(CONNECTION_STRING);
OleDbCommand myCommand = new OleDbCommand("INSERT INTO rtf_table (rtf_title, rtf_content) VALUES ('" + title + "', ?)", myConnection);
OleDbParameter myParameter = new OleDbParameter("@rtf",OleDbType.VarWChar);
myParameter.Value = rtf;
myCommand.Parameters.Add(myParameter);
//open the connection and execture the statement
myConnection.Open();
myCommand.ExecuteNonQuery();
}
finally
{
myConnection.Close();
}
}
These are some related links:
OleDbType Enumeration vs. Microsoft Access Data Types:
http://support.microsoft.com/kb/320435.
OleDb namespace:
http://msdn.microsoft.com/en-us/library/system.data.oledb(VS.71).aspxOleDb instruction:
http://msdn.microsoft.com/en-us/library/ms722784(VS.85).aspx.
Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.