Solved

mysql insert staement not working

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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