0

Hi,
I want to use VB.NET to connect to sql server remotely and input and receive data from the server. Can anyone help me to do it? I really appreciate code example. Thank you very much!!

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by __avd
0

Welcome hjdaniel.sun.

Here are steps:
1. Create or Open Project (application)
2. Import System.Data.SqlClient and System.Data namespaces.
3. Create an instance of SqlConnection class

Sub Test()
     Dim Cn as New System.Data.SqlClient.SqlConnection
     cn.ConnectionString="Data Source=servername;Initial Catalog=databasename;User Id=username;Password=password"
    cn.Open()
    ....
    cn.Close()
 End Sub
0

Thank you, very much.
So, is System.Data.SqlClient.SqlConnection a built-in control in .NET Framework?

0

It is not a control but it is a provider class of ADO.NET class lib.

System.Data.SqlClient is a namespace and SqlConnection is class.
Classes represented by System.Data namespace is called "ADO.NET" class lib.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.