New topic: 

When does ODBCDatabase.DatabaseName get updated?

<http://forums.realsoftware.com/viewtopic.php?t=45593>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        kreed          Post subject: When does ODBCDatabase.DatabaseName 
get updated?Posted: Fri Oct 12, 2012 3:09 pm                         
Joined: Fri Oct 12, 2012 1:18 pm
Posts: 1                I have been testing ODBC access to my SQL Server 2008 
database system. The RB ODBC class works well, except for one curious behavior: 
The DatabaseName property seems to be ignored.

Assuming the source code:
dim db as odbcDB
db = new odbcDB
// then I would expect something like this to work to preset the default 
database defined in the ODBC manager:
//now connect to database Foo
db.Connect()

//now what is the database name?

  dim dbName as string = db.DatabaseName
  MsgBox( "Database " + dbName)

// returns null

Additional testing shows that if I set db.DatabaseName to something prior to 
connection, it still does nothing. The database I get is the database specified 
in the ODBC DSN

Testing shows that connection does not overwrite the default database spec in 
the ODBC Manager. Nor does it update the database name after being connected.

If not preset, connecting to the database server does not update the database 
name property:

db.DatabaseName is still null

When is this property set? As far as I can tell, it does nothing. I realize I 
can kludge this with a "Use <db name>" query, but this seems really lame. Of 
course I also know that I need to fully qualify queries, but I still want my 
user to be able to set the database he wants to see.

Any ideas?   
                             Top                Jym          Post subject: Re: 
When does ODBCDatabase.DatabaseName get updated?Posted: Fri Oct 12, 2012 3:45 
pm                         
Joined: Sat Oct 01, 2005 5:19 pm
Posts: 3152                I only use it for attaching databases.  If you set 
it to something then I guess you can use that something in the SQL?  But not 
really sure

db.DatabaseName = "Whatever"

db.SQLExecute("SELECT * FROM whatever.Table") 

maybe?  But it's something you set not something that comes from the database.  
 
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to