Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:27:08+00:00 2026-06-15T10:27:08+00:00

I am trying to connect to database at window form level in Studio 2010/VB.Net.

  • 0

I am trying to connect to database at window form level in Studio 2010/VB.Net. I am using two different databases in Sql 2008r2. One database I am using to populate records at form load event (run time) and when users pick their selection or any modification from that form, data should be updated to other database by instert, update, delete and save commands for user’s future reference.

Is it possible to connect with two different databases using one Connection String?

Do I need to add two database name in below mentioned code somewhere?

Imports System.Data.SqlClient

Dim con As New SqlClient.SqlConnection("data source=DATASOURCE;initial catalog=NAME OF DATABASE;Integrated Security=True")
Dim cmd As New SqlCommand()    
cmd.Connection = con    
con.Open()    
con.Close()

OR

Should I use two database below somewhere?

Imports System.Data.SqlClient

Public Class NEW_PERSONAL_INFORMATION

  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    Dim con As New SqlClient.SqlConnection("data source=ROOM310-40\SQLEXPRESS;initial catalog=DTIS;Integrated Security=True")

    Dim cmd As New SqlCommand()    
    cmd.Connection = con    
    con.Open()    
    con.Close()
  End Sub

End Class

Apologies If I am seeking help in simple thing or not able to explain it enough.

I would appreciate any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:27:10+00:00Added an answer on June 15, 2026 at 10:27 am

    I can’t tell what you’re asking, so I’ll give two answers.

    If you’re trying to connect to two different servers then you’ll need two different connection strings. In fact, you’ll need two different SqlConnections, and you’ll need to keep track of which connection is which.

    Dim con1 As New SqlClient.SqlConnection("data source=ROOM310-40\SQLEXPRESS;initial catalog=DTIS;Integrated Security=True")
    Dim con2 As New SqlClient.SqlConnection("data source=ROOM310-40-2\SQLEXPRESS;initial catalog=DTIS;Integrated Security=True")
    

    If you’re talking about multiple catalogs on the same server, then you don’t need multiple connections. You can just specify the catalog name directly in your query:

    SELECT MyColumn FROM MyDatabase1.dbo.MyTable;
    SELECT MyColumn FROM MyDatabase2.dbo.MyTable;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to a database with two tables. However, after I
I am trying to connect to a sql database with the following code line
I'm trying to connect to a MySQL 5 database using the MySQL ODBC 5.1
I am trying to connect to an Oracle Database using nHibernate. I can connect
I am trying to connect to oracle database from c++ using OCCI, I am
I'm trying to connect to a database on my host machine (windows xp, sql
I'm trying to feed data from SQL database to FLEX, using php script in
I'm trying to connect to my database stored in my SQL Azure platform. My
I am trying to make a form using Oracle form Builder. I can connect
I'm trying to connect to a database using Windows Authentication. I believe that my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.