I am creating a Windows forms application and my SQL Server database is on a remote server. How can I connect to it using Visual C# and ADO.NET?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You need to investigate the
SqlConnection,SqlCommandand possibleSqlDataReaderandSqlDataAdaptercomponents in .NET (see the MSDN online docs).Once you have that, you need to define your connection string – check that site link for a huge selection and explanation of connection strings.
Then you basically connect using:
and you can do stuff in various ways, e.g. by filling data sets, reading values etc.
Read the MSDN ADO.NET Overview to get started! Or Google for “ADO.NET tutorial” – you’ll find tons of links.