To connect to a sql 2005 server, you will need to know:
- The server name
- your user name
- your password
If you are an Aquest Hosting customer, then this information is provided to you when you add a SQL database to your account.
Hi,
Can anyboday tell me how to connect the clien and server in SQL Server 2005.
Thanks & Regards
Hiren Patel
![]() |
0 |
![]() |
Hi, here is a sample function that you can use to connect to sql server.
The "sql" is your sql command that you can pass to be queried on the SQL Server.
-> i.e. "SELECT FirstName, LastName FROM Accounts WHERE Password = '" & txtPassword & "';"
The "Data Source" is the address of your SQL Server
The "Initial Catalog" is database that you want to access
The "User" and "Pwd" is your account on the SQL Server
-> if the SQL Server is the same location with your IIS you can use "Integrated Security=SSIP" instead
The function will return a DataTable in which you manipulate
-> set it as a DataSource to DataGrid/GridView
-> i.e.
With GridView
.DataSource = QueryDatabase(mySQL)
.DataBind()
End With
Note: Code is in VB 20051 Public Shared Function QueryDatabase(ByVal sql As String) As DataTable
2
3 ' SQL Server Connection Object Variable
4 Dim _oConnection As SqlConnection
5 ' SQL Server Command Object Variable
6 Dim _oCommand As SqlCommand
7 ' SQL Server Data Adapter Object Variable
8 Dim _oAdapter As SqlDataAdapter
9 ' DataTable Object Variable (Early Binding)
10 Dim _oDataTable As New DataTable
11
12 ' Instantiate Connection Object with connection string
13 _oConnection = New SqlConnection("Data Source=XXX.XXX.XXX.XXX;Initial Catalog=XXXXXX;User=XXX;Pwd=XXX;")
14 ' Instantiate Command Object with SQL String and Connection Object
15 _oCommand = New SqlCommand(sql, _oConnection)
16 ' Instantiate Data Adapter Object with Command Object
17 _oAdapter = New SqlDataAdapter(_oCommand)
18 ' Fill the DataTable Object with the retrieve records
19 _oAdapter.Fill(_oDataTable)
20
21 ' Release resources used by DataAdapter Object
22 _oAdapter.Dispose()
23
24 ' Release resources used by Command Object
25 _oCommand.Dispose()
26
27 ' Close the connection of the Connection Object from SQL Server
28 _oConnection.Close()
29
30 ' Release resources used by Connection Object
31 _oConnection.Dispose()
32
33 ' Return the retrieve records
34 Return _oDataTable
35
36 End Function
Please don't forget to click "Answer" if it helps you as it may help others also.
![]() |
0 |
![]() |
Hi patelhiren20,
To connect to a sql 2005 server, you will need to know:
- The server name
- your user name
- your password
If you are an Aquest Hosting customer, then this information is provided to you when you add a SQL database to your account.
Requirements:
You can connect to a SQL Server 2005 database using SQL Server Management Studio.
If you are using SQL Server 2005 Express Edition, which is available free from
http://msdn.microsoft.com/vstudio/express/sql/, then you can not upload your database in this manner. Unfortunately, the Express version does not allow you to copy your database to a remote server (our server), but it will allow you to build a database on a remote server. If you are using the Express Edition and need to copy your database to our server, you will need to detach..........click here to see a much more detailed information on how to connect to a sql 2005 server: http://www.aquesthosting.com/HowTo/Sql2005/connect.aspx
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
![]() |
0 |
![]() |
Hi patelhiren20,
To connect to a sql 2005 server, you will need to know:
- The server name
- your user name
- your password
If you are an Aquest Hosting customer, then this information is provided to you when you add a SQL database to your account.
Requirements:
You can connect to a SQL Server 2005 database using SQL Server Management Studio.
If you are using SQL Server 2005 Express Edition, which is available free from
http://msdn.microsoft.com/vstudio/express/sql/, then you can not upload your database in this manner. Unfortunately, the Express version does not allow you to copy your database to a remote server (our server), but it will allow you to build a database on a remote server. If you are using the Express Edition and need to copy your database to our server, you will need to detach..........click here to see a much more detailed information on how to connect to a sql 2005 server: http://www.aquesthosting.com/HowTo/Sql2005/connect.aspx
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
![]() |
0 |
![]() |