[thelist] SQL Server default db with ancient ASP

Max Schwanekamp lists at neptunewebworks.com
Thu Dec 28 17:09:58 CST 2006


Peter Brunone (EasyListBox.com) wrote:
>    Just grasping at straws here, but what if you (a) remove the spaces after the semicolons, and (b) change "Data Source" to " 
> 		ServerName"?

Thanks, but no dice.  Changing the Data Source bit to ServerName results 
in an "Invalid connection string attribute" error.  But the connection 
is made, and queries *can* run, it's just that the default database 
("Initial Catalog") attribute of the connection seems to get ignored.  I 
even tried doing it after the connection is opened:
strConn = "Provider=sqloledb;Data Source=sql.example.com,1433;User 
Id=dbuser;Password=dbpass;Initial Catalog=mydatabase;"
conn.Open(strConn)
conn.DefaultDatabase = 'mydatabase'

'' error "Invalid Object mytable":
Set rs = conn.Execute("SELECT * FROM mytable")

'' works OK:
Set rb = conn.Execute("SELECT * FROM mydatabase.mytable")

Since my post, I also tried explictly creating then opening the recordset:

Set rs = CreateObject("ADODB.RecordSet")
'' also gives error "Invalid Object mytable"
rs.Open "SELECT * FROM mytable", conn, adOpenStatic, adLockReadOnly

I'm guessing this is a security setting I've not encountered before. 
For now I'm just putting in the database name in the queries for each 
script on an as-needed basis (ugh), but any suggestions/hints/guesses 
would be appreciated.


-- 
Max Schwanekamp
NeptuneWebworks.com
541-517-9064



More information about the thelist mailing list