[Help] remote sql connection

Posts 115 of 19 · Page 1 of 2
[Help] remote sql connection
k, i'v been searching, and trying so many things and not comingup with any way of doing this.

basicly, i want it to do this.

button clicked:
--username.txt to a string
--password.txt to a string
open remote connection with username and password to remote connection

if sucsessfull, msgbox "hello world"
if not, msgbox "error"

thats it.
this is what i'v got...most complete code...
Code:
Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  conn = New MySqlConnection()
  conn.ConnectionString = "server=" & "server IP" & ";" _
    & "user id=" & txtUsername.Text & ";" _
    & "password=" & txtPassword.Text & ";" _
    & "database= usertable"

  Try
    conn.Open()
    MessageBox.Show("user accepted, application starting")
    conn.Close()
    frmbrowser.show()
    me.close()
  Catch myerror As MySqlException
    MessageBox.Show("incorrect password")
  Finally
    conn.Dispose()
  End Try
End Sub
anybody tell me where im going wrong?
Code:
conn.ConnectionString = string.format("server=" & "server IP" & ";" & "user id=" & txtUsername.Text & ";" & "password=" & txtPassword.Text & ";" & "database= usertable")
Try that.
Quote Originally Posted by mnpeepno2 View Post
Code:
conn.ConnectionString = string.format("server=" & "server IP" & ";" & "user id=" & txtUsername.Text & ";" & "password=" & txtPassword.Text & ";" & "database= usertable")
Try that.
Why would you use String.Format and then put no formatting in though .

@Poster, what's the actual problem? You just said is anything wrong, which apparently there isn't (at least with this section of code) so what's the problem? Not logging in?
Quote Originally Posted by Jason View Post


Why would you use String.Format and then put no formatting in though .

@Poster, what's the actual problem? You just said is anything wrong, which apparently there isn't (at least with this section of code) so what's the problem? Not logging in?
its in string format -.-
Quote Originally Posted by mnpeepno2 View Post
its in string format -.-
Do you know what string.format even is?
Quote Originally Posted by *****179 View Post
k, i'v been searching, and trying so many things and not comingup with any way of doing this.

basicly, i want it to do this.

button clicked:
--username.txt to a string
--password.txt to a string
open remote connection with username and password to remote connection

if sucsessfull, msgbox "hello world"
if not, msgbox "error"

thats it.
this is what i'v got...most complete code...
Code:
Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  conn = New MySqlConnection()
  conn.ConnectionString = "server=" & "server IP" & ";" _
    & "user id=" & txtUsername.Text & ";" _
    & "password=" & txtPassword.Text & ";" _
    & "database= usertable"

  Try
    conn.Open()
    MessageBox.Show("user accepted, application starting")
    conn.Close()
    frmbrowser.show()
    me.close()
  Catch myerror As MySqlException
    MessageBox.Show("incorrect password")
  Finally
    conn.Dispose()
  End Try
End Sub
anybody tell me where im going wrong?
Do you actually put the serverIP in the connection string? And are you sure the username you're putting in is the UserID for the database? You've got to have the right database credentials.
Quote Originally Posted by *****179 View Post
k, i'v been searching, and trying so many things and not comingup with any way of doing this.

basicly, i want it to do this.

button clicked:
--username.txt to a string
--password.txt to a string
open remote connection with username and password to remote connection

if sucsessfull, msgbox "hello world"
if not, msgbox "error"

thats it.
this is what i'v got...most complete code...
Code:
Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  conn = New MySqlConnection()
  conn.ConnectionString = "server=" & "server IP" & ";" _
    & "user id=" & txtUsername.Text & ";" _
    & "password=" & txtPassword.Text & ";" _
    & "database= usertable"

  Try
    conn.Open()
    MessageBox.Show("user accepted, application starting")
    conn.Close()
    frmbrowser.show()
    me.close()
  Catch myerror As MySqlException
    MessageBox.Show("incorrect password")
  Finally
    conn.Dispose()
  End Try
End Sub
anybody tell me where im going wrong?
Your connection string has the literal text "Server IP" in it. You're supposed to replace that with the actual server address or IP.
Quote Originally Posted by freedompeace View Post
Your connection string has the literal text "Server IP" in it. You're supposed to replace that with the actual server address or IP.
That's what I said, but he could have just changed it out so we don't steal his server IP
i did change it.
details are correct.
mnpeep, tryed it. nothing happened...
Try this:

private conn as new mysqlconnection(String.Format("server={0};user id={1};password={2};database={3};", ip,username,password,database))

I guess the last ; is missing.
Quote Originally Posted by Blubb1337 View Post
Try this:

private conn as new mysqlconnection(String.Format("server={0};user id={1};password={2};database={3};", ip,username,password,database))

I guess the last ; is missing.
You don't need a final semicolon though?
My connection string didn't end in a semicolon and I've never had problems with it
Quote Originally Posted by Jason View Post
My connection string didn't end in a semicolon and I've never had problems with it
I just wanted to make sure it isn't such stupid mistake


He should just tell us what error he's getting.
Quote Originally Posted by Blubb1337 View Post
I just wanted to make sure it isn't such stupid mistake


He should just tell us what error he's getting.
Yeah, guess we just have to wait on his feedback now.
Posts 115 of 19 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Need help?