Go Back   Novahq.net Forum > Computers > Web design and Programming

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-24-2021, 11:38 PM
~BLÃÐE~ is offline ~BLÃÐE~
Registered User

Join Date: Dec 2004
Location: Gold Coast, Australi
Posts: 241

Send a message via ICQ to ~BLÃÐE~
Connecting to Database

Hi guys im working on a chat app, i watched the video got the source code and nothing worked lol.

Anyways after some time and code change i got it working mostly properly on xampp. The DB works as do the tables....i imported it to my web hosted server but can't connect no matter what i try...

Whats need to go from xampp to my hosted phpmyadmin?
Yes i left the root and no password as i didn't want to post my details, but i did change them.

Code:
Imports System.IO
Imports System.Security.Cryptography
Imports MySql.Data.MySqlClient

Module DataModule1
    Public con As New MySqlConnection("server=localhost" & My.Settings.Host & "; user=root" & My.Settings.User & "; password=" & My.Settings.Pass & "; database=chat_db " & My.Settings.dbName)

    Public usernamefriend As String
    Public Sub Connect()
        If con.State = ConnectionState.Open Then
            con.Close()
            con.Open()
        Else
            con.Open()
        End If
    End Sub

    Public Function login(username As String, password As String)
        Connect()
        Dim cmd As New MySqlCommand("select * from users where username = @username and password = @password", con)
        cmd.Parameters.AddWithValue("@username", username)
        cmd.Parameters.AddWithValue("@password", password)
        Dim dt As New DataTable
        Dim dr As MySqlDataReader = cmd.ExecuteReader
        dt.Load(dr)
        Return dt
    End Function

Last edited by ~BLÃÐE~; 01-25-2021 at 01:16 AM.
Reply With Quote
  #2  
Old 01-25-2021, 10:23 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Sometimes web hosts have a different server than "localhost". Have you tried adjusting that? There really shouldn't be a difference between xampp and a web host except the server, database name, username and password and possibly the port but that would be unusual.
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 01-27-2021, 01:42 PM
~BLÃÐE~ is offline ~BLÃÐE~
Registered User

Join Date: Dec 2004
Location: Gold Coast, Australi
Posts: 241

Send a message via ICQ to ~BLÃÐE~
Got it working, the host had to change some settings, i had to change the server name (which wasn't listed in there list)

Yes i thought it was much the same but just couldn't work it out, thanks Scott now i can get on with some of the other problems i have with it lol.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:12 PM.




Powered by vBulletin®