Hi
I am getting error - Syntax error in Update statement. I am using VB6
str1 = "update Camera_config set login='" & (txtLogin.Text) & _
"', password='" & EncryptP(Trim(txtPwd.Text)) & _
"', channel= " & Val(cmbChannel.Text) & _
", camera_IP='" & Trim(txtIP.Text) & "'"
cnn1.Execute str1
Thanks
Daniel WrightPosted Apr 15, 2025, 4:39 PM
It looks like the Syntax error in your Update statement might be due to missing a crucial element in your SQL query. Let's break it down a bit:
Your SQL update statement:
From the provided code snippet, it seems like you are trying to update a table called "Camera_config" with the values provided in the VB6 form fields.
To properly diagnose the Syntax error, we need to ensure that all the input values are correctly formatted in the SQL query. Here are a couple of things you should check:
1. Make sure that the values being concatenated into the SQL query are properly escaped and formatted. It's essential to handle special characters properly to avoid SQL injection vulnerabilities. For instance, `txtLogin.Text` should be sanitized if it contains user input.
2. Check if the `EncryptP` function is returning the expected string format for the SQL query. Ensure that it is not introducing any syntax errors.
3. Verify that all the fields in the `Camera_config` table are spelled correctly and exist in the database.
To further assist you, could you provide more details on the specific error message you are encountering? Additionally, examining the constructed SQL query (i.e., the value of `str1`) before executing it could help pinpoint where the Syntax error occurs.
Feel free to share any additional information or error messages for us to provide a more precise solution.