jakebur01 Posted April 20, 2007 Share Posted April 20, 2007 Hello, I just got started with Visual Basic a few weeks ago. I have a text field named txtZipbox and a button named btnZip. I am wanting to retrieve the data WHERE my Zip column = what someone typed in the txtZipbox. I get an error back saying that txtZipbox.Text is not a column. I know that it's not a column. What do I need to add onto this to make it happen? `Jake Private Sub btnZip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZip.Click Dim conn As New MySqlConnection Dim myCommand As New MySqlCommand Dim myAdapter As New MySqlDataAdapter Dim myData As New DataTable Dim SQL As String SQL = "SELECT * FROM smithssc WHERE Zip = txtZipbox.Text" conn.ConnectionString = myConnString Try conn.Open() Try myCommand.Connection = conn myCommand.CommandText = SQL myAdapter.SelectCommand = myCommand myAdapter.Fill(myData) dgvStatus.DataSource = myData dgvStatus.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells Catch myerror As MySqlException MsgBox("There was an error reading from the database: " & myerror.Message) End Try Catch myerror As MySqlException MessageBox.Show("Error connecting to the database: " & myerror.Message) Finally If conn.State <> ConnectionState.Closed Then conn.Close() End Try End Sub Link to comment https://forums.phpfreaks.com/topic/47838-solved-visual-basic-mysql/ Share on other sites More sharing options...
bubblegum.anarchy Posted April 20, 2007 Share Posted April 20, 2007 I can't remember the concat symbol for VB - replace the & with what ever symbol VB uses SQL = "SELECT * FROM smithssc WHERE Zip = "'" & txtZipbox.Text & "'" Link to comment https://forums.phpfreaks.com/topic/47838-solved-visual-basic-mysql/#findComment-233750 Share on other sites More sharing options...
jakebur01 Posted April 20, 2007 Author Share Posted April 20, 2007 that concat is right. I'm getting: There was an error reading from the database: You have an error in you SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 1 Link to comment https://forums.phpfreaks.com/topic/47838-solved-visual-basic-mysql/#findComment-233753 Share on other sites More sharing options...
bubblegum.anarchy Posted April 20, 2007 Share Posted April 20, 2007 LOL - my bad sorry.. remove the extra quote " SQL = "SELECT * FROM smithssc WHERE Zip = "'" & txtZipbox.Text & "'" to SQL = "SELECT * FROM smithssc WHERE Zip = '" & txtZipbox.Text & "'" Link to comment https://forums.phpfreaks.com/topic/47838-solved-visual-basic-mysql/#findComment-233795 Share on other sites More sharing options...
jakebur01 Posted April 20, 2007 Author Share Posted April 20, 2007 Man. You don't know how much I appreciate you helping me. It works great now. Thanks. Link to comment https://forums.phpfreaks.com/topic/47838-solved-visual-basic-mysql/#findComment-233806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.