nnuswantari
Programmer
I have any data that show in datagridview
ex:
column name = ID Number, name, Company, salary
1st data:{001, Miss NN, CV Mellow, 500}
2nd data:{002, Mr. I , CV Mafia, 800}
3th data:{003,Miss MK, GORILA'CC , 200}
I will save them to a table in Access database (eg: tbl_salary)
my structure's table is:
IDnumber : char(3)
name : char(50)
company : char(50)
salary : int
But, I have problem during insert 3th data {003, Miss MK, GORILA'CC, 200}; because a field [company] contain character apostrophe (GORILA'CC) .
Error message:
ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''GORILA'CC',200)'.
What can I do to solve this problem?
Please tell me about it. Thanx
ex:
column name = ID Number, name, Company, salary
1st data:{001, Miss NN, CV Mellow, 500}
2nd data:{002, Mr. I , CV Mafia, 800}
3th data:{003,Miss MK, GORILA'CC , 200}
I will save them to a table in Access database (eg: tbl_salary)
my structure's table is:
IDnumber : char(3)
name : char(50)
company : char(50)
salary : int
Code:
Dim CNString As String = ""
Dim DtConn As OdbcConnection
CNString = "Driver=XXX....;"
DtConn = New OdbcConnection(CNString
For i As Integer = 0 To Me.DataGridView1.RowCount - 1
Dim id As String = Me.DataGridView1.Rows(i).Cells(0).Value
Dim name As String = Me.DataGridView1.Rows(i).Cells(1).Value
Dim comp As String =Me.DataGridView1.Rows(i).Cells(2).Value
Dim sal As String = Me.DataGridView1.Rows(i).Cells(3).Value
Dim cmdr As New OdbcCommand("INSERT INTO tbl_miss VALUES ('" & id & "','" & name & "','" & comp & "'," & sal & ")", DtConn)
DtConn.Open()
cmdr.ExecuteNonQuery()
DtConn.Close()
Next
But, I have problem during insert 3th data {003, Miss MK, GORILA'CC, 200}; because a field [company] contain character apostrophe (GORILA'CC) .
Error message:
ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''GORILA'CC',200)'.
What can I do to solve this problem?
Please tell me about it. Thanx