Hello Friend,
I have a problem writing a string into a MS Access database. The code is in SQL but the platform is in VB.NET. Below is my code.
OleDataAdapter.InsertCommand.CommandText = _
"INSERT INTO Expense(Amount, Dates, Debit, Credit, " & _
"ExpenseType, PaymentMethod, Summary) " & _
"VALUES(" & Val(txtAmount.Text) & " , " & _
"" & CType(txtDate.Text, DateTime) & " , " & _
"'" & radDebit.Checked & "' , '" & radCredit.Checked & "' , " & _
"'" & cboExpType.SelectedItem & "' , " & _
"'" & cboPayMethod.SelectedItem & "' , " & _
"" & txtSummary.Text & ""
Problem: The problem is that the code work just fine. However, when I try to enter a string in the summary box that contain a string ' such as don't, it will not work. I know that string concatenation in SQL is not good. Is there an esay way to fix this so I can enter text into a database that contain word such as don't, doesn't (where an extra ' is being added)?
I have a problem writing a string into a MS Access database. The code is in SQL but the platform is in VB.NET. Below is my code.
OleDataAdapter.InsertCommand.CommandText = _
"INSERT INTO Expense(Amount, Dates, Debit, Credit, " & _
"ExpenseType, PaymentMethod, Summary) " & _
"VALUES(" & Val(txtAmount.Text) & " , " & _
"" & CType(txtDate.Text, DateTime) & " , " & _
"'" & radDebit.Checked & "' , '" & radCredit.Checked & "' , " & _
"'" & cboExpType.SelectedItem & "' , " & _
"'" & cboPayMethod.SelectedItem & "' , " & _
"" & txtSummary.Text & ""
Problem: The problem is that the code work just fine. However, when I try to enter a string in the summary box that contain a string ' such as don't, it will not work. I know that string concatenation in SQL is not good. Is there an esay way to fix this so I can enter text into a database that contain word such as don't, doesn't (where an extra ' is being added)?