Click here to Skip to main content
15,919,434 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to insert Special character like 44'12 in ms access database using asp.net C#

What I have tried:

How to insert Special character like 44'12 in ms access database using asp.net C#
Posted
Updated 19-May-17 9:26am
Comments
phil.o 19-May-17 8:15am    
Please see the FAQ :)
CHill60 19-May-17 8:33am    
Show us how you are currently trying to do it and what goes wrong. 44'12 is not a "special" character, it is 5 quite normal characters, so also explain what you are trying to do
[no name] 19-May-17 8:45am    
If you are using Access for a web site, you have bigger problems than trying to insert a string into a database.

1 solution

Follow the instruction: c# - Inserting special chars (such as ' or +) into an Access database - Stack Overflow[^]

C#
string myString = TextBox1.Text;
string cmdText = "INSERT INTO myTable (MY_FIELD) VALUES (@name)";
using(OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ThePathToYourDatabaseFileHere.accdb;Persist Security Info=False;"))
using(OleDbCommand comm = new OleDbCommand(cmdText, conn))
{
     conn.Open();
     comm.Parameters.Add("@name", OleDbType.VarWChar).Value = myString;
     comm.ExecuteNonQuery();
}


Try!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900