Access Insert issue
-
I am trying to insert a record into an Access 2007 DB. I am having an issue with a Memo field. I have tried double quotes, single quotes. I am at a loss on how to load this sentence: This is a Test If anybody has any ideas or sample code I would really appreciate.
-
I am trying to insert a record into an Access 2007 DB. I am having an issue with a Memo field. I have tried double quotes, single quotes. I am at a loss on how to load this sentence: This is a Test If anybody has any ideas or sample code I would really appreciate.
-
Have you looked at the Samples that come with Access? Have you looked for information on the Access Developer site[^]?
led mike
Do they examples of doing this using C#?
-
I am trying to insert a record into an Access 2007 DB. I am having an issue with a Memo field. I have tried double quotes, single quotes. I am at a loss on how to load this sentence: This is a Test If anybody has any ideas or sample code I would really appreciate.
An insert query for that is rather simple. Example:
insert into someTable (aMemoField) values ('This is a test...')
When you do it from code you should use a parameterised query, though. Then you don't have to worry about apostrophes and correctly escaping strings (which is rather crucial to protect against SQL injection attacks).Despite everything, the person most likely to be fooling you next is yourself.
-
An insert query for that is rather simple. Example:
insert into someTable (aMemoField) values ('This is a test...')
When you do it from code you should use a parameterised query, though. Then you don't have to worry about apostrophes and correctly escaping strings (which is rather crucial to protect against SQL injection attacks).Despite everything, the person most likely to be fooling you next is yourself.
Here is my updated Code utlizing a parameterised query. I still get an error on my Insert Command stating: Syntax error in INSERT INTO statement. The first field is a key and is a long int The second field is a Text Field 255 long Here is the code that does the insert. Please let me know of any issues. I can't find any: string commandText = "INSERT INTO Contact_Notes (Contact_ID,Note) VALUES(@Contact_ID,@Note)"; string strConcat = "**** " + g_ProfName + " " + DateTime.Now.ToString() + " **** " + txtNewNote.Text; conProspect.Open(); OleDbCommand cmd = new OleDbCommand(commandText,conProspect); cmd.Parameters.Add("@Contact_ID", lngContactId); cmd.Parameters.Add("@Note", strConcat); cmd.ExecuteNonQuery(); conProspect.Close(); cmd.Dispose(); As always thanks for all the help
-
Here is my updated Code utlizing a parameterised query. I still get an error on my Insert Command stating: Syntax error in INSERT INTO statement. The first field is a key and is a long int The second field is a Text Field 255 long Here is the code that does the insert. Please let me know of any issues. I can't find any: string commandText = "INSERT INTO Contact_Notes (Contact_ID,Note) VALUES(@Contact_ID,@Note)"; string strConcat = "**** " + g_ProfName + " " + DateTime.Now.ToString() + " **** " + txtNewNote.Text; conProspect.Open(); OleDbCommand cmd = new OleDbCommand(commandText,conProspect); cmd.Parameters.Add("@Contact_ID", lngContactId); cmd.Parameters.Add("@Note", strConcat); cmd.ExecuteNonQuery(); conProspect.Close(); cmd.Dispose(); As always thanks for all the help
If I remove the Note field. It works just fine...
-
Do they examples of doing this using C#?
kruegersck wrote:
Do they examples of doing this using C#?
kruegersck wrote:
I still get an error on my Insert Command stating: Syntax error in INSERT INTO statement.
If you have any intention of becoming a capable software developer I suggest you stop typing questions into forums and start researching and reading your own information. It is as valuable a skill and activity of a developer as any other, period.
led mike
-
Here is my updated Code utlizing a parameterised query. I still get an error on my Insert Command stating: Syntax error in INSERT INTO statement. The first field is a key and is a long int The second field is a Text Field 255 long Here is the code that does the insert. Please let me know of any issues. I can't find any: string commandText = "INSERT INTO Contact_Notes (Contact_ID,Note) VALUES(@Contact_ID,@Note)"; string strConcat = "**** " + g_ProfName + " " + DateTime.Now.ToString() + " **** " + txtNewNote.Text; conProspect.Open(); OleDbCommand cmd = new OleDbCommand(commandText,conProspect); cmd.Parameters.Add("@Contact_ID", lngContactId); cmd.Parameters.Add("@Note", strConcat); cmd.ExecuteNonQuery(); conProspect.Close(); cmd.Dispose(); As always thanks for all the help