error System.Data.SqlClient.SqlException: 'Incorrect syntax near '´'.' in VB.NET (Windows Forms)

Mariwa 21 Reputation points
2022-12-06T20:55:46.483+00:00

Im on vb.net framework version 4.8.1
Using an online database

code

Public Class register
Private cmd As SqlCommand

Private Sub register_btn_Click(sender As Object, e As EventArgs) Handles register_btn.Click  

    Dim con As New SqlConnection  
    Dim unused As New SqlCommand  

    con.ConnectionString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\XXXXX\Desktop\XXXXXXX\XXXXXXXX\Database1.mdf;Integrated Security=True"  
    con.Open()  


    If (fname.Text = "" Or lname.Text = "" Or gender.Text = "" Or phone.Text = "" Or email.Text = "" Or password.Text = "") Then  
        MessageBox.Show("XXXXXXX")  
    Else  
        cmd = New SqlCommand("INSERT INTO users values(´" & fname.Text & "´,´" & lname.Text & "´,´" & gender.Text & "´,´" & phone.Text & "´,´" & email.Text & "´,´" & password.Text & "´) ", con)  
        cmd.ExecuteNonQuery()  
        MsgBox("XXXXX", MsgBoxStyle.Information, "XXXXXXX")  
        Me.Hide()  
        Login.Show()  
        fname.Clear()  
        lname.Clear()  
        phone.Clear()  
        email.Clear()  
        password.Clear()  
    End If  
    con.Close()  


End Sub
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,579 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
944 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.5K Reputation points
    2022-12-06T21:04:30.88+00:00

    Try normal apostrophes ' instead of ´.

    To avoid further major problems, consider the Parameterized Queries instead of dangerous string concatenations.

    0 comments No comments

0 additional answers

Sort by: Most helpful