Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB and MySQL help please
#2
update,

have not fixed first problem but I can get the code to post with a single database entry but if I try multiple I get the original error.

Code:
Imports MySql.Data.MySqlClient

Public Class frmMain
    Public conn As MySqlConnection
    Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Dim NAME As Boolean = True
        conn = New MySqlConnection("server=db4free.net;Port=3306;user id=PRIVATE;password=PRIVATE;database=PRIVATE")
        conn.Open()
        Dim sqlquery As String = "SELECT * FROM reloads WHERE Name = '" & txtName.Text & "';"
        Dim data As MySqlDataReader
        Dim adapter As New MySqlDataAdapter
        Dim command As New MySqlCommand
        command.CommandText = sqlquery
        command.Connection = conn
        adapter.SelectCommand = command
        data = command.ExecuteReader
        While data.Read()
            If data.HasRows() = True Then
                MsgBox("Name Already in use!")
                NAME = False
                data.Close()
            Else
                data.Close()
                NAME = True
            End If
        End While
        data.Close()
        If NAME = True Then
            Dim sqlquery2 As String = "INSERT INTO reloads (name) VALUES(1)"
            MsgBox(sqlquery2)
            Dim data2 As MySqlDataReader
            Dim adapter2 As New MySqlDataAdapter
            Dim command2 As New MySqlCommand
            command2.CommandText = sqlquery2
            command2.Connection = conn
            adapter2.SelectCommand = command2
            data2 = command2.ExecuteReader
            MsgBox("Data Added")
        Else
            MsgBox("No Data Entered")
        End If
    End Sub
End Class


Messages In This Thread
VB and MySQL help please - by Chad1020 - 03-20-2012, 10:41 PM
Re: VB and MySQL help please - by Chad1020 - 03-21-2012, 12:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I read a link from mysql databse??? mnxford 9 33,042 04-12-2013, 06:27 PM
Last Post: brandonio21
  How do I use Listview to delete MySQL DB records kismetgerald 10 33,859 11-28-2012, 05:19 PM
Last Post: brandonio21
  [SOLVED] MySQL Update Query - What am I doing wrong? kismetgerald 11 43,324 10-18-2012, 07:16 PM
Last Post: brandonio21
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,714 10-14-2012, 09:05 PM
Last Post: brandonio21
  Help with creating an INSERT statement using MySQL kismetgerald 4 16,758 08-30-2012, 03:03 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 29,057 08-13-2012, 08:58 PM
Last Post: brandonio21
  MySql Database Queries in VB.Net Moldraxian 6 22,383 07-26-2012, 03:44 PM
Last Post: Moldraxian
  How to Package MySql Connector and MySql Program? Moldraxian 3 14,755 07-20-2012, 12:23 PM
Last Post: brandonio21
  MySql Help Blackrobot 3 14,623 04-06-2012, 03:49 AM
Last Post: xolara
  MySQL Help -Kid- 6 25,408 02-20-2012, 11:57 AM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)