Hi
Having trouble with the UPDATE query, it workd perfectly fine when there is no unicode symbol in the textbox but gives me the following error when unicode is present.
Edit:
I am using .RTF format and Access DB
Syntax error (missing operator) in query expression ''{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Cambria;}} \viewkind4\uc1\pard\f0\fs23 jh\'b1\'b1\'b1hreyt43562435\super 63216846821598935921985098370957093270426dsgdsrgtfdhg\nosupersub\par } ', Question.Question_No = 1 WHERE Que'.
Here is the code for the SQL statement
Adding and selecting data works fine as well its just the Update that is a problem Here are the codes for Add and Select
For selecting
Having trouble with the UPDATE query, it workd perfectly fine when there is no unicode symbol in the textbox but gives me the following error when unicode is present.
Edit:
I am using .RTF format and Access DB
Syntax error (missing operator) in query expression ''{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Cambria;}} \viewkind4\uc1\pard\f0\fs23 jh\'b1\'b1\'b1hreyt43562435\super 63216846821598935921985098370957093270426dsgdsrgtfdhg\nosupersub\par } ', Question.Question_No = 1 WHERE Que'.
Here is the code for the SQL statement
VB.NET:
Dim cmdUpdateQs As OleDb.OleDbCommand
cmdUpdateQs = New OleDb.OleDbCommand("UPDATE [Question] SET Question.Question = '" & rtbQuestion.Rtf & "', Question.Question_No = " & lblQuestion_No.Text & _
" WHERE Question.Question_ID =" & grdQuestions.SelectedRows.Item(0).Cells(0).Value, myconnection.GetConnection)
cmdUpdateQs.ExecuteNonQuery()
Adding and selecting data works fine as well its just the Update that is a problem Here are the codes for Add and Select
VB.NET:
Dim cmdAddQuestion As OleDb.OleDbCommand
cmdAddQuestion = New OleDb.OleDbCommand("INSERT INTO Question(Question_No, Question, Quiz_ID) Values (QN,Q,QI)", myconnection.GetConnection)
cmdAddQuestion.Parameters.AddWithValue("QN", GetTotalQs() + 1)
cmdAddQuestion.Parameters.AddWithValue("Q", rtbQuestion.Rtf)
cmdAddQuestion.Parameters.AddWithValue("QI", GetQuizID(combQuiz_Title.SelectedItem))
Cleared = False
cmdAddQuestion.ExecuteNonQuery()
For selecting
VB.NET:
Dim DA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT Question.Question_ID, Question.Question_no, Question.Question" & _
" FROM Question INNER JOIN Quiz ON Quiz.Quiz_ID = Question.Quiz_ID" & _
" WHERE Question.Quiz_ID =" & GetQuizID(combQuiz_Title.SelectedItem) & " ORDER BY Question.Question_No", myconnection.GetConnection)
Dim DS As DataSet = New DataSet
DA.Fill(DS, "Question")
grdQuestions.DataSource = DS.Tables("Question")
Last edited: