Results 1 to 4 of 4

Thread: Access SQL SERVER Database and Access Database in the same program

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    Access SQL SERVER Database and Access Database in the same program

    Dear Friends,

    I am designing a software in C# with SQL Server and Access as backend databases. Can anyone please help me how to access both the databases in C#. I am designing the software on a Windows XP PC.

    Thank You

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Access SQL SERVER Database and Access Database in the same program

    The fact that you're connecting to both isn't really relevant. You would connect to each one the same way as you would if it was the only one. Are you saying that you don't know how to connect to just one? If so then you might like to follow the CodeBank link in my signature and check out my Retrieving & Saving Data thread for some ADO.NET examples. You might also like to follow the Data Walkthroughs link for some higher-level how-to topics.

  3. #3
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Smile Re: Access SQL SERVER Database and Access Database in the same program

    I am designing a software in C# with SQL Server and Access as backend databases. Can anyone please help me how to access both the databases in C#. I am designing the software on a Windows XP PC.
    i assume your connection string is ok .and it is open.so try the following way .

    Code:
    try
    {
        SqlDataReader myReader = null;
        SqlCommand    myCommand = new SqlCommand("select * from table", 
                                                 myConnection);
        myReader = myCommand.ExecuteReader();
        while(myReader.Read())
        {
            Console.WriteLine(myReader["Column1"].ToString());
            Console.WriteLine(myReader["Column2"].ToString());
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
    }

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    Re: Access SQL SERVER Database and Access Database in the same program

    Thank You very much Friends for your suggestions. It worked fine. Even I had used # of Access in SQL Query.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width