Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,836 members, 7,817,469 topics. Date: Saturday, 04 May 2024 at 12:47 PM |
Nairaland Forum / Science/Technology / Programming / Vb.net With Mysql (873 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)
Social Media Widget Feature On A Phpbb Forum? / Version 0.1.1 Of BUCKETJS Library Released / Autocad Traning
(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 |