0

hi there im currently do some simple webpage that can submit the data save into database into MYSQL Workbench. But currently i have an error for insert into table. The error is ---------------------------

App_Web_kclqmsmh

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change,reasonchange,problem,priority,reasondescription,systemrequest) VALUES ('C' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change,reasonchange,problem,priority,reasondescription,systemrequest) VALUES ('C' at line 1

OK

Below is the code of mine. am using ASP.net then using VB as my backend langues

Inline Code Example Here

Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient


Partial Class Request

    Inherits System.Web.UI.Page

    Dim MessageBox As Object
    Dim Emplid, Nama, DeptDesc, email, change, reasonchange, problem, priority, reasondescription, systemrequest As String
    Dim date1 As Date




    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        txt1.Focus()
        txt2.Focus()
        txt3.Focus()
        txt4.Focus()
        txt5.Focus()
        txt6.Focus()
        txt7.Focus()
        ddl1.Focus()
        ddl2.Focus()
        ddl3.Focus()
        ddl4.Focus()
    End Sub

    Protected Sub btnsubmit_Click(sender As Object, e As EventArgs) Handles btnsubmit.Click


        'Create sql connection and fetch data from database based on employee id

        Dim conn As New MySql.Data.MySqlClient.MySqlConnection

         dim strConnectionString As String = ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString

        Try
            conn.ConnectionString = strConnectionString
            conn.ConnectionString = "server=localhost;user id=root;persistsecurityinfo=False;database=test;password=1234"
            conn.Open()

        Catch ex As MySql.Data.MySqlClient.MySqlException
            MessageBox.Show(ex.Message)
        End Try



        Dim cr_id As String
        Dim empl_id As String
        empl_id = "301992MS"
        cr_id = "CR004"
        Dim iReturn As Boolean
        Using SQLConnection As New MySqlConnection(strConnectionString)
            Using sqlCommand As New MySqlCommand()
                sqlCommand.Connection = SQLConnection
                With sqlCommand
                    .CommandText = "INSERT INTO cr_record(idcr_record,Emplid,Nama,date1,DeptDesc,email,change,reasonchange,problem,priority,reasondescription,systemrequest) VALUES (@cr_id,@Emplid,@Nama,@date1,@DeptDesc,@email,@change,@reasonchange,@problem,@priority,@reasondescription,@systemrequest)"
                    .CommandType = Data.CommandType.Text
                    .CommandTimeout = 5000
                    .Parameters.AddWithValue("@cr_id", cr_id)
                    .Parameters.AddWithValue("@Emplid", empl_id)
                    .Parameters.AddWithValue("@Nama", txtname.Text)
                    .Parameters.AddWithValue("@date1", txt5.Text)
                    .Parameters.AddWithValue("@DeptDesc", txt2.Text)
                    .Parameters.AddWithValue("@email", txt4.Text)
                    .Parameters.AddWithValue("@change", ddl2.Text)
                    .Parameters.AddWithValue("@reasonchange", txt6.Text)
                    .Parameters.AddWithValue("@problem", ddl3.Text)
                    .Parameters.AddWithValue("@priority", rbl1.Text)
                    .Parameters.AddWithValue("@reasondescription", txt7.Text)
                    .Parameters.AddWithValue("@systemrequest", ddl4.Text)
                End With
                Try
                    SQLConnection.Open()
                    sqlCommand.ExecuteNonQuery()
                    iReturn = True
                    MsgBox("Added Successfully")
                Catch ex As MySqlException
                    MsgBox(ex.Message.ToString & Err.Description)
                    iReturn = False
                Finally
                    SQLConnection.Close()
                End Try
            End Using
        End Using
        Return
    End Sub
End Class


**im try fix this error but seem noting change..**
1
Contributor
1
Reply
14
Views
3 Years
Discussion Span
Last Post by Razaleigh
0

yeah finally i found the solution for this i will upload the code that make my web works and can save into my sql db. hopefully all of you can teach me how to capture the data fill into textbox using the mysql

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.