Stats: 3,190,121 members, 7,939,532 topics. Date: Wednesday, 04 September 2024 at 07:50 AM |
Nairaland Forum / Science/Technology / Programming / Vb.net With Mysql (902 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` ); " ![]() 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)
Why Does Nairaland Ban Important & Useful Information/Threads? / Joomla Help Asap / (URGENT!) For Those Who Are Conversant With CMS.
(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. 12 |