does anyone has a sample code or it it possible to fix error in this code
I appreciate any advice

the error i get :
There was an error parsing the query. [ Token line number = 1,Token line offset = 13,Token in error = user ]
cmd.ExecuteNonQuery()

Imports System.Data.SqlServerCe
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Dim con As New OleDbConnection
        Dim con As SqlCeConnection = New SqlCeConnection("DataSource=C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\samples\Northwind.sdf;Persist Security Info=False")


        Dim CmdStr As String = "insert into user (emp_name,category,city) values ('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
        con.Open()
        Dim cmd As SqlCeCommand = New SqlCeCommand(CmdStr, con)
        cmd.ExecuteNonQuery()
        con.Close()
        MsgBox("Done")
    End Sub

   

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim con As SqlCeConnection = New SqlCeConnection("DataSource=C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\samples\Northwind.sdf;Persist Security Info=False")
       
        Dim Query2 As String = "select * from user"
        Dim DA As SqlCeDataAdapter, Ds As New DataSet, Dtb As New System.Data.DataTable

        con.Open()
        Da = New SqlCeDataAdapter(Query2, con)
        DA.Fill(Ds)
        con.Close()
        Dtb = Ds.Tables(0)
        DataGridView1.DataSource = Dtb

    End Sub

Edited 5 Years Ago by __avd: Correct [code] tags.

User is reserved keyword of MS-SQL.

Dim CmdStr As String = "insert into [user] (emp_name,category,city) values ('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
Dim Query2 As String = "select * from [user]"
This question has already been answered. Start a new discussion instead.