Solved

mysql insert staement not working

Posted on 2006-11-30
2
180 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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