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
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.
Re: Access SQL SERVER Database and Access Database in the same program
Quote:
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());
}
:wave:
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.