i am trying to use MySQL 5 and asp.net 4
i succeed withe the linking and display the data from MySQL DB but the problem is within the DML Commands !!
please take a look to my code
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyConnection As String = "server=localhost;User Id=root;password=123;database=cms"
Dim Connection As New MySqlConnection(MyConnection)
Connection.Open()
Dim Sql As String = "INSERT INTO [CMS.tbimages] ( Title,Description) VALUES (parm2,parm3);"
Dim cmd As New MySqlCommand(Sql, Connection)
cmd.Parameters.Add(New MySqlParameter("parm2", "hajjaj"))
cmd.Parameters.Add(New MySqlParameter("parm3", "hajjaj"))
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Sub
End Class
what i did is a simple page for testing the insert command , I added a button when i click on it it should do the insert command!!
but when i click it it gives me error :
#42000 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 '[CMS.tbimages] ( Title,Description) VALUES (parm2,parm3)' at line 1
not : i tried many other ways to change the insert statement :
"INSERT INTO [tbimages] ( [Title], [Description]) VALUES ( ? , ?)"
"INSERT INTO [tbimages] ([Title], [Description])
VALUES (?Title , ?Description)"
INSERT INTO [tbimages] ( [Title], [Description]) VALUES (Title, Description)