Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,155,900 members, 7,828,174 topics. Date: Wednesday, 15 May 2024 at 04:25 AM |
Nairaland Forum / Science/Technology / Programming / Vb.net With Mysql (877 Views)
Generating Crystal Report With MYSQL Database For A VB.NET Application / Genrating Crystal Report With Mysql Database In A Vb.net Application / How To Connet C++ Mfc Application With Mysql (2) (3) (4)
(1) (Reply)
Vb.net With Mysql by jboy01(m): 3:31pm On Jul 05, 2013 |
pls am creating an application that involve database with vb.net, but i the application did not insert the input field in the database. this is my code. Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click Dim myConnectionString As String myConnectionString = "server=127.0.0.1;" _ & "uid=root;" _ & "pwd=;" _ & "database=data_book;" Try Dim conn As New MySql.Data.MySqlClient.MySqlConnection(myConnectionString) conn.Open() Catch ex As MySql.Data.MySqlClient.MySqlException Select Case ex.Number Case 0 MessageBox.Show("Cannot connect to server. Contact administrator" Case 1045 MessageBox.Show("Invalid username/password, please try again" End Select End Try Try Dim cmd As New MySqlCommand(String.Format("INSERT INTO `data_book` (`id`, `first_name`, `middle_name`, `last_name`, `sex`, `mar_status`, `state`, `local_gov`, `home_add`, `office_add`, `phone_no`, `email`) " & _ "VALUES (NULL , '{0}', '{1}',`firName.text`, `midName.text`, `lstName.text`, `sex.text`, `marStar.text`,`stOrigin.text`, `lclGov.text`, `homeAdd.text`, `officeAdd.text`, `phNum.text`, `email.text` ); ", conn) cmd.ExecuteNonQuery() Catch ex As Exception MsgBox("Your Record Added Successfully!", MsgBoxStyle.Information, "Successful!" End Try cmd.CommandText = "INSERT INTO 'data_book' (first_name, middle_name, last_name, 'sex', mar_status, state, local_gov, home_add, office_add, phone_no, email) " & _ "VALUES (firName.text, midName.text, lstName.text, sex.text, marStar.text,""stOrigin.text"", ""lclGov.text"", ""homeAdd.text"", ""officeAdd.text"", ""phNum.text"", ""email.text"" ); " End Sub |
Re: Vb.net With Mysql by dellnet: 5:03pm On Jul 05, 2013 |
At has to throw an error somewhere. Definitely your INSERT STATEMENT is wrong change Catch ex As Exception MsgBox("Your Record Added Successfully!", MsgBoxStyle.Information, "Successful!") End Try to Catch ex As Exception MsgBox(ex.Message) End Try post back the error |
(1) (Reply)
Whats The Minimum Laptop Specs For Programming / Hnd/bsc Or IT Certifications / Lend Your Voice This The Dying Children
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |