Connect to anothe database

Discussion in 'ASP .Net Security' started by Husam, May 30, 2007.

  1. Husam

    Husam Guest

    Hi EveryBody:

    How can I connect to another database instaed of the default database
    aspnetdb in the local SQL Server in the App_Data folder that exist in my web
    site application ?

    My database that I want to connect is in my local Machine and its name=Husam.

    Any Help or redirection will be completely appreciated

    regard's

    Husam
    Husam, May 30, 2007
    #1
    1. Advertising

  2. On May 30, 10:42 am, Husam <> wrote:
    > Hi EveryBody:
    >
    > How can I connect to another database instaed of the default database
    > aspnetdb in the local SQL Server in the App_Data folder that exist in my web
    > site application ?
    >
    > My database that I want to connect is in my local Machine and its name=Husam.
    >
    > Any Help or redirection will be completely appreciated
    >
    > regard's
    >
    > Husam


    You should connect a database using connection string.

    Example of connection string for SQL Server 2000

    Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated
    Security=SSPI;

    More examples you can find here
    http://www.connectionstrings.com/?carrier=sqlserver

    string cs = "Data Source=myServerAddress;Initial
    Catalog=myDataBase;Integrated Security=SSPI;"
    using (SqlConnection cn = new SqlConnection(cs))
    {
    SqlCommand cmd = new SqlCommand();
    .....
    Alexey Smirnov, May 30, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Otis Mukinfus
    Replies:
    3
    Views:
    904
    Juan T. Llibre
    Jul 8, 2005
  2. =?Utf-8?B?VHJleSBNaXRjaGVsbA==?=

    ASP.Net querying Active Directory works on one page and not anothe

    =?Utf-8?B?VHJleSBNaXRjaGVsbA==?=, Jul 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    378
    =?Utf-8?B?VHJleSBNaXRjaGVsbA==?=
    Jul 19, 2005
  3. =?Utf-8?B?SHVzYW0=?=

    Connect to anothe database

    =?Utf-8?B?SHVzYW0=?=, May 30, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    279
    Jon Paal [MSMD]
    May 30, 2007
  4. Greg Hauptmann
    Replies:
    1
    Views:
    162
    Tony Arcieri
    Dec 8, 2009
  5. Replies:
    2
    Views:
    271
Loading...

Share This Page