Solved

mysql insert staement not working

Posted on 2006-11-30
2
179 Views
Last Modified: 2010-04-23
here is the code Im using, code compiles without errors, but no records in DB

        Dim SqlString As String = "INSERT INTO profiles (nom, prenom, doorNumber, address) VALUES (" & TextBox1.Text & ", " & TextBox2.Text & ", " & TextBox8.Text & ", " & TextBox9.Text & ")"



        Try
            Using conn As New MySql.Data.MySqlClient.MySqlConnection(myConnectionString)
                Using cmd As New MySql.Data.MySqlClient.MySqlCommand(String.Format(SqlString), conn)
                    conn.Open()
                End Using
            End Using
        Catch ex As MySql.Data.MySqlClient.MySqlException
            MessageBox.Show(ex.Message)
        End Try
0
Comment
Question by:prowebinteractive
2 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 500 total points
ID: 18047230
Some of those variables look like strings, though, so I suspect you'll end up with a query like this:
INSERT INTO profiles (nom, prenom, doorNumber, address) VALUES (x y z, foo bar, 3, an address goes here);

That, clearly, isn't valid SQL.  Try:
        Dim SqlString As String = "INSERT INTO profiles (nom, prenom, doorNumber, address) VALUES ('" & TextBox1.Text & "', '" & TextBox2.Text & "', " & TextBox8.Text & ", '" & TextBox9.Text & "')"

(noting the quote marks around the variables I believe are strings -- naturally amend that to reflect which ones are ACTUALLY strings (-:  )
0
 

Author Comment

by:prowebinteractive
ID: 18048305
I updated that issue but the query is still not happening
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now