devxlogo

Make Sure You are Connected to the Right Database

Make Sure You are Connected to the Right Database

When issuing SQL statements against SQL Server, consider fully equating all of your table or procedure names to include the database name, especially if you are using an existing data source. Users have the ability to change the default database for their data source, which could cause your program (SQL calls) to fail because they can’t find what you are talking about. You can also define the database you are connecting to when you open a connection, which will override the users’ default.

 Private Sub LoadGrid()    Dim sSql as string    'Example of specifying full name of database and table    sSql = "select * from pubs.dbo.authors " &_              "where au_lname = 'Smith'"    _End Sub

devx-admin

Share the Post: