Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created an SQL database on my domain server and installed phpMyAdmin to log into the sql database but when i try to connect i get an error on the open code, i have put my code below


VB
Imports MySql.Data.MySqlClient
Imports System.Data
Imports System.Data.SqlClient

Public Class frmLogincreator

Private Sub btncreate_Click(sender As Object, e As EventArgs) Handles btncreate.Click
       Dim cn As New MySqlConnection
       Dim Command As New MySqlCommand
       Dim reader As MySqlDataReader

       cn.ConnectionString = "server= ****************.**.**/phpMyAdmin; user id= *************; password =*****************; database = stockin1_password"
       Command.Connection = cn
       cn.Open()
       Command.CommandText = " SELECT username,password FROM Login WHERE username= '" & txtusername.Text & "' AND Password = '" & txtpassword.Text & "'"

       reader = Command.ExecuteReader
       If reader.HasRows Then
           MsgBox("Username or Password already exist Please enter a Diferent Username or Password!", MsgBoxStyle.Critical, "Checkpoint")
       Else
           Command.Dispose()
           reader.Dispose()
           Command.CommandText = "Insert into Login (Username, Password, ClientName, ClientSurname) values('" & txtusername.Text & "','" & txtpassword.Text & "','" & txtname.Text & "','" & txtsurname.Text & "')"
           Command.ExecuteNonQuery()
           MsgBox("Information Successfully saved!/ Account Generation Succeed!", MsgBoxStyle.Information, "Information Generation")
           txtusername.Clear()
           txtpassword.Clear()
       End If

   End Sub
Posted
Updated 9-Jun-14 14:57pm
v3
Comments
Peter Leow 9-Jun-14 7:15am    
What error? Is the ConnectionString correct?
[no name] 9-Jun-14 7:28am    
I doubt your connection string is correct.

1 solution

I never did any work with vb.net. But here is few things you need to understand.

1. You gave the world the access link for your database which can be accessed through phpmyadmin along with your password.(which i guess either stupid or its a test/learning site)
2. when you say server "stockinvestments.co.za" is your server not "stockinvestments.co.za/phpMyAdmin".
3. stockinvestments.co.za/ is an http server and /phpMyAdmin is uri. it is not even clear whether your mysql allows you to access from other then localhost.
3. phpMyAdmin is a php based application to do simple operation on mysql server but it is not any kind of service or server.
4. cn is a MySqlConnection connection not httpconnection.

if your mysql server is properly configured then you can access the server from outside world. But it is not I already have checked :) cause your username and password is also there............... if it is proper then your connection string would be

C#
cn.ConnectionString = "server=server-name; user id= *************; password =*****************; database = stockin1_password"


and using your mysql client, I use only mysql commandline client, you can connection from anywhere on earth using those info.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900