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!!

Recommended Answers

All 3 Replies

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.