SQL-Server Database Connect with the SqlDatabase-Variable

General discussion forum about all databases other than SqlBase.
booky

SQL-Server Database Connect with the SqlDatabase-Variable

Post by booky » 23 Nov 2007, 18:55

Hello.



I have one question:



I work with the SQL-Server 2005 and with the team developer. For it I'm using the SqlUDL-String (with the information provider, persist security info and initial catalog), the SqlUser-Variable, the SqlPassword-Variable and the SqlDatabase-Variable. Therefore I must set the SqlDatabase-Variable to the value of the server-name.



Set SqlUDL = 'Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=DB;'

Set SqlDatabase = 'server'

Set SqlUser = 'user'

Set SqlPassword = 'pwd'



That functions good, but why must I set the server-name to the SQLDatabase-Variable? Is that a bug?



Thanks, booky

Jean-Marc Gemperle

Re: SQL-Server Database Connect with the SqlDatabase-Variable

Post by Jean-Marc Gemperle » 23 Nov 2007, 20:03

Hi There,



No this is not a bug, but I agree it can be confusing in the case of SQLServer and Sybase and maybe some other databases that requires the catalog property in the connection string as well as MS OLEDB to ODBC.



The SqlUDL feature is normally used along with SqlConnect() to ease/quick move from native connectivity to OLEDB, so to say( though you can set SqlUDL and give it in the last argument of SqlCreateSession()).



Anyway in your case the connection string that you pass in your SqlUDL does not contain the Data Source. If you would have provided the Data Source and all other mendatory OLEDB properties like this



Set SqlUDL='Provider=SQLOLEDB.1;Password=support;Persist Security Info=True;User ID=support;Initial Catalog=Gupta;Data Source=JMG-LAPTOP'



Then you could skip to set all the 'traditional' system variables SqlDatabase/User/Password and you would connect. The Minimum in SqlUDL must be the Provider name or a UDL file name. In this case by using those traditional system variables TD build and complements internaly its connection string. So in your case you had to set the data source and you did correctly by seting SqlDatabase to the SQLServer server name...



IMO, it is safe to say that SqlDatabase when using OLEDB represents the Data Source of an OLEDB connection string, not the catalog if this is what you meant...and confused you.



So IMO I don't see any bug in that other than the fact that the Database system variable is NOT the Database what ever that mean in the context of any back-end, but the Data Source when using OLEDB.



Hope I was convincing :-)



Cheers



Jean-Marc

booky

Re: SQL-Server Database Connect with the SqlDatabase-Variable

Post by booky » 26 Nov 2007, 12:11

Hi jmgemperle,



thanks for your answer.



booky

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 6 guests