This forum is in read-only mode for archive purposes, please use our new forum at https://community.justflight.com
Forum Home Forum Home > Just Chat > Just Chat - General Discussion
  New Posts New Posts RSS Feed - ODBC DB Connection - No Database Selected
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ODBC DB Connection - No Database Selected

 Post Reply Post Reply
Author
Message
VulcanB2 View Drop Down
Chief Pilot
Chief Pilot
Avatar

Joined: 02 Apr 2008
Points: 13365
Post Options Post Options   Thanks (0) Thanks(0)   Quote VulcanB2 Quote  Post ReplyReply Direct Link To This Post Topic: ODBC DB Connection - No Database Selected
    Posted: 03 May 2008 at 12:04am
Hi,

I'm going mad here trying to fix this one!! It seems that no-one knows the answer to this!

My dev system is able to talk to the remote DB server (MySQL 5.0). It works fine, no issues.

When I put my ASP.NET pages onto the server (IIS 5.0, Win2K Server, .NET 2.0), it suddenly decides to tell  me "No Database Selected"!

Here is the code concerned:

Imports System
Imports System.Data
Imports System.Data.Odbc
'...

        Dim dbCS As String = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=<SERVERIP>; DATABASE=<DATABASE>; UID=<USERNAME>; PASSWORD=<PASSWORD>; PORT=3306"
        ' I tried DSNs too, but they throw the same error.
        'Dim dbCS As String = "DSN=<DATABASE>;PORT=3306" 'OPTION=3"
        Dim dbConn As New OdbcConnection(dbCS)
        dbConn.Open()

        Dim DBPass, DBAdmin As String

        Dim dbQuery As String = "SELECT password, admin FROM users WHERE username='" & LCase(txtUser.Text) & "'"
        Dim dbExec As New OdbcCommand(dbQuery, dbConn)
        dbExec.Connection = dbConn ' This line apparently doesn't do anything
****        Dim dbReader As OdbcDataReader = dbExec.ExecuteReader ' This line errors
        dbReader.Read()
        Try
            DBPass = dbReader.GetString(0)
            DBAdmin = dbReader.GetString(1)
        Catch
            'MsgBox("User doesn't exist!", MsgBoxStyle.Exclamation, "")
            lblErr.Text = "Invalid User"
            lblErr.Visible = True
            Exit Sub
        Finally
            dbReader.Close()
            dbConn.Close()
        End Try


Anyone here know how to fix this??? As I say, it works fine on my dev computer, but screws up when the ASP pages are put on the server. I doubt it is a bug in the ODBC drivers for MySQL as I'm using the same versions on my dev computer as the server.

Best regards,
Vulcan.
Back to Top
VulcanB2 View Drop Down
Chief Pilot
Chief Pilot
Avatar

Joined: 02 Apr 2008
Points: 13365
Post Options Post Options   Thanks (0) Thanks(0)   Quote VulcanB2 Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2008 at 12:48am
0MG!!!!! The spaces in the connect string are stopping it working on the server!!!!

This WORKS:


Dim dbCS As String = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=<SERVER>;UID=<USERNAME>;PASSWORD=<PASSWORD>;DATABASE=<DATABASE>;PORT=3306"


Best regards,
Vulcan.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down