Need help with mysql vb not connecting
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
9 posts
Page 1 of 1
Herro pippsy har my derm title says it all I can not seem to get this to work, well it works but it never connects to any db i am trying to use it with 000webhost.com or other hosting sites for db, and it decides to never connect when i test any ideas here is a snippet to work with, and edit please if anyone finds a way let me know or if i can get a vb source for a php script that can connect this ? 
- Pip

Code: Select all
Thanks in advancedImports MySql.Data.MySqlClient
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MysqlConn As New MySqlConnection
MysqlConn.ConnectionString = ("port=" & port.text & ";server=" & txtServer.Text & ";user id= " & txtUsername.Text & "; password= " & txtPassword.Text & "; database= " & txtdbname.Text & "; pooling=false")
Try
MysqlConn.Open()
MessageBox.Show("Connection to Database has been opened.")
MysqlConn.Close()
Catch myerror As MySqlException
MessageBox.Show("Cannot connect to database: " & myerror.Message)
Finally
MysqlConn.Dispose()
End Try
End Sub
End Class
- Pip
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
Does anyone know I still have not found a solution tried alot so far.... :|
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
First try this way and then try with your textboxes
Code: Select all
EDIT : bit longtime ago i wrote something about what you want on my blog http://ultimateprogrammingtutorials.blo ... se-in.html maybe that also could help youPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyConnection.ConnectionString = "server=localhost;" _
& "user id=root;" _
& "password=root;" _
& "database=DB_Test;"
MyConnection.Open()
End Sub
Find my programs on Softpedia
mshimranpro wrote:First try this way and then try with your textboxes
Code: Select allEDIT : bit longtime ago i wrote something about what you want on my blog http://ultimateprogrammingtutorials.blo ... se-in.html maybe that also could help youPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MyConnection.ConnectionString = "server=localhost;" _ & "user id=root;" _ & "password=root;" _ & "database=DB_Test;" MyConnection.Open() End Sub
Right well what is another web hosting site or sites that you know of that works with this ? i think it might just be ghetto 000webhost cause it is same error not connecting to the database.
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
pip wrote:Code: Select all- PipImports MySql.Data.MySqlClient Imports System.Data.SqlClient Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim MysqlConn As New MySqlConnection MysqlConn.ConnectionString = ("port=" & port.text & ";server=" & txtServer.Text & ";user id= " & txtUsername.Text & "; password= " & txtPassword.Text & "; database= " & txtdbname.Text & "; pooling=false") Try MysqlConn.Open() MessageBox.Show("Connection to Database has been opened.") MysqlConn.Close() Catch myerror As MySqlException MessageBox.Show("Cannot connect to database: " & myerror.Message) Finally MysqlConn.Dispose() End Try End Sub End Class
Code: Select all
not sure, but what i do know if you don't have a sql installed on your pc this will never works. MysqlConn.ConnectionString = ("port=" & port.text & "; server=" & txtServer.Text &"; Port=" & port.text & "; user id=" & txtusername.text & "; password=" & txtpassword.text & "; database=" & txtdbname.text &";"
i know i tried before

i think you need AccessDatabaseEngine.exe or mysql-connector-net on microsoft website
i can be wrong about the file but i know you miss something on your pc
to use this part of code.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
i used to have the same problem with 000webhost.com, turns out that they don't provide remote access. You can use it in PHP scripts, but they will work only after uploading it to their servers 

visualtech wrote:i used to have the same problem with 000webhost.com, turns out that they don't provide remote access. You can use it in PHP scripts, but they will work only after uploading it to their servers#visualtech So what sites do host that allow remote access? I need a list so i know what to base project around.
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
i use hostgator.com and it works like magic or try freehostingnoads.net. One more solution can be that you create a PHP file which actually takes the values from the app and then echoes back a response say name:username
parse it in your app!
parse it in your app!
@ #visualtech Ok so the parsing thing i have this code so far:
and php script: http://uppit.com/clksf5mlo7ox/dbconnect.rar
I got the post thing, but how can i get it to check the string then popup msg saying connected or not, and can you maybe proof my script and code?
Code: Select all
Imports System.IO
Imports System.Text
Imports System.Net
Public Class Form1
Public Function PHP(ByVal url As String, ByVal method As String, ByVal data As String)
Try
Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(url)
request.Method = method
Dim postData = data
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
Return (responseFromServer)
Catch ex As Exception
Dim error1 As String = ErrorToString()
If error1 = "Invalid URI: The format of the URI could not be determined." Then
MsgBox("ERROR! Must have HTTP:// before the URL.")
Else
MsgBox(error1)
End If
Return ("ERROR")
End Try
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim htmlcode As String = PHP("http://pipware.site90.net/dbconnect.php", "POST", "dbname=" & txtdbname.Text & "&dbusername=" & txtUsername.Text & "&dbpass=" & txtPassword.Text & "&dbhost=" & txtServer.Text & "")
End Sub
End Class
and php script: http://uppit.com/clksf5mlo7ox/dbconnect.rar
I got the post thing, but how can i get it to check the string then popup msg saying connected or not, and can you maybe proof my script and code?
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
9 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023