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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist