Jump to content



Photo

Vb Code To Make Database Connection.(Not Working, Simple Solution I Think)

visual basic vb mysql database connect connection .net coding programming visualbasic

  • Please log in to reply
2 replies to this topic

#1 xBluefire

xBluefire

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 09 December 2014 - 03:56 PM

Hello, I got this code in VB:

    Dim connStr As String = "Database=x13a6c333x_test;" & _
        "Data source=94.249.139.6/phpmyadmin/;" & _
        "User Id=x13a6c333x_Ask;Password=*****(DB Password I use to login with at 94.249.139.6/phpmyadmin/)"
    Dim connection As New MySqlConnection(connStr)

 

Inside that DB i Created a table Users

 

which brings us to this:
        Console.WriteLine(updateRecord("INSERT INTO users (username, password) VALUES ('" & txtUsername.Text & "', '" & txtPassword.Text & "')"))
 

and this is the function updateRecord:
    Function updateRecord(ByVal query As String) As Integer
        Try
            Dim rowsEffected As Integer = 0
            Dim connection As New MySqlConnection(connStr)
            Dim cmd As New MySqlCommand(query, connection)

            connection.Open()

            rowsEffected = cmd.ExecuteNonQuery()

            connection.Close()

            Return rowsEffected
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Function

 

Why does the table users not get the things filled in the textboxes? There is no error at all and I don't see the problem.

Thanks in advance!



#2 ekifox

ekifox

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 29 December 2014 - 05:35 PM

Made a php script with mysql connect. And by this php script update your db.

--

<?php

$conn = mysql_connect('123','123','123');

mysql_select_db('123');

mysql_query($conn, $_GET['sql']);

?>

--

http query: yoursite.com/script.php?sql=INSERT+INTO+users+(username,password)+VALUES+('" & txtUsername.Text & "','" & txtPassword.Text & ");



#3 Bonar

Bonar

    Advanced Member

  • Members
  • PipPipPip
  • 181 posts
  • Location/home

Posted 26 January 2015 - 02:09 PM

There are so many good article about that, which one of them is here: http://www.codeproje...es-using-VB-NET


Nothing to display at the moment. RIP






Also tagged with one or more of these keywords: visual basic, vb, mysql, database, connect, connection, .net, coding, programming, visualbasic

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users