Solved

mysql insert staement not working

Posted on 2006-11-30
2
178 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
Comment Utility
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
Comment Utility
I updated that issue but the query is still not happening
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now