Client/Server Connectivity in SQL Server 2005

Hi,

Can anyboday tell me how to connect the  clien  and server in SQL Server 2005.

Thanks & Regards

 

 

 

 


Hiren Patel
0
patelhiren20
7/25/2007 4:47:42 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
939 Views

Similar Articles

[PageSpeed] 59
Get it on Google Play
Get it on Apple App Store

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 2005

1    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
jobejufranz
7/25/2007 5:00:30 AM

Hi patelhiren20,

 

To connect to a sql 2005 server, you will need to know:

  1. The server name
  2. your user name
  3. 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
Bo
7/30/2007 6:27:49 AM

Hi patelhiren20,

 

To connect to a sql 2005 server, you will need to know:

  1. The server name
  2. your user name
  3. 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
Bo
7/30/2007 6:28:18 AM
Reply:

Similar Artilces:

This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers
When I connect SQL Server 2005 to a remote database i get the error: "This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers". Can I confirm it is because: the remote db is of SQL Server 2008? There is a soln mentioned in http://forums.asp.net/t/1324047.aspx Did anybody try this (installing 2008 express: http://www.microsoft.com/express/sql/download/)? I am just checking again, whether it will disturb my existing SQL Server installation, in any means...? Though it is mentioned that it will g...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all
When i enter log in, I get the following error page.    Server Error in '/' Application. An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the err...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all #2
I get the following error and have been trying to figure out why I keep getting it.  Initially, I had placed my project under wwwroot folder and ran it under IIS and it gave this error.  Then I moved it to my local C drive and same thing.  I am sharing this project with two other co-workers and all our config files and code files are same...they don't get this error but I do.  I checked that SQL Server Client Network Utility has TCP/IP and the 'Named Pipes' enabled.  I thought maybe I have setting in the Visual Studio 2005 that I'm not aware of that&#...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allo
My site works fine in VWD2008 express, but I get this error when I try to use it on my live website. An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.  According to this article: http://support.microsoft.com/kb/914277  I am supposed to: 1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration. Ok, th...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all #3
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, Hi  I think you are trying to connect with remote server using windows authentication mode.Sql won't allow this ,so try to connect with server using sql authentication mode with(username and password)Happy ProgrammingShashi.  Check if this thread on the same discussion can help.http://forums.asp.net/p/1193329/2062685.aspx...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all #5
An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)   <sessionState mode="SQLServer"sqlConnectionString="data source=LHX00CNU7401SQG\Session; integrated security=true"/>   I have done all the settings: --> enabling the protocols --> Starting teh SQlbrowser but still no luck. Pleas...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all #6
hi there! I've uploaded my website at online server. which has its database on its local server. Now whenever Im trying to open the website. I get the following message instead of website. "An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) " Im using sql server 2000 for database. Asp.net 2.0 Please hel...

Error : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does
Hi All, i am using tha conncetion string in web.config. <add name="MyLocalSqlConnection" connectionString="Data Source=.\SqlExpress;AttachDbFilename=|DataDirectory|\SqlServer\OC00003SQL.mdf;User Instance=false" providerName="System.Data.SqlClient"/>  Instance=false and true both i have used  but i am getting error like that. on my web hosting site  Error : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Serv...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not all #4
Hi,I have SQL Server Express Edition. I tried working out some ASP.NET Labs in my local system. Here is the link of the Virtual Lab which I tried. http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032286906&EventCategory=3&culture=en-US&CountryCode=USI recieve this error in my local system. An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Cou...

Error while establishing a connection to the SQL server 2005
Hi, I had an old web application created during asp.net 1.1 and it have a connection problem with the sql server 2005 when it is mirgrated to a new webserver with dotnet framework 2.0 platform. I have enabled the remote access(TCP/IP and named pipes) in sql server 2005, did all the neccessary things, check whether the TCP/IP is enabled, named pipe is enabled...  I created another web application using VS 2005. The database connection works perfectly well.This are the connectionString from the old web application.<appSettings>    <add key="ConnectionString" value=...

SQL Server 2000 and SQL Server 2005 in the same server
Can enyone please send me a link to a white paper explaining how to run both SQL Server 2000 and 2005 in the same machine?Thanks. I don't know about the white paper but I had both running on my machine for a while by making the SQL 2000 a named instance. So for SQL 2005 connection strings my server name was (local) while for SQL 200 using the named instance it was (local)\joesql where joesql was the instance nameHope it helps,Joe http://www.joeaudette.comhttp://www.mojoportal.com...

Connecting to SQL Server 2000 with SQL Server 2005
I currently have Enterprise 2000 installed but would like to uninstall and install SQL Server 2005. Are there any problems if I try to reconnect to other SQL 2000 servers or other serious issues I need to consider before doing this change ?   Thanks,...

SQL Express
Hi,I have SQL Server Express Edition. I tried working out some ASP.NET Labs in my local system. Here is the link of the Virtual Lab which I tried. http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032286906&EventCategory=3&culture=en-US&CountryCode=USI recieve this error in my local system. An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Cou...

SQL Server 2005 Installation problems with SQL Server Express & SQL Server 2000
Hi Guys, I have had SQL Server Express and Sql Server Management Studio Express installed on my machine for some time and recently tried to install a trial of SQL Server 2005 as well.  (Yes, I'm migrating from Visual Studio Express to Visual Studio Professional, just as in tended!) Everything went fine except that nothing seemed to be installed.  I searched in all the obvious places - both on the Start/Programs menu and on the hard-drive: nothing. A check under Add/Remove Programs showed that Sql Server 2005 Express was installed, but called SQL Server 2005. So after a number o...

Web resources about - Client/Server Connectivity in SQL Server 2005 - asp.net.sql-datasource

TE Connectivity - Wikipedia, the free encyclopedia
TE Connectivity Ltd. designs and manufactures connectivity and sensor solutions for a variety of industries including automotive, industrial ...

Mark Zuckerberg Goes Into Detail On Facebook Connectivity Lab, Internet.org
Perhaps Facebook Co-Founder and CEO Mark Zuckerberg is just a wee bit excited about the Connectivity Lab , the initiative aimed at using high-altitude ...

The power of connectivity
By Keven McCammon, site data center manager, Facebook Forest City Data Center Today we announced that we’re partnering with the Town of Forest ...

Facebook, Internet.org launch Connectivity Lab
... CEO Mark Zuckerberg shed some light on the company’s acquisition of drone-maker Titan Aerospace, announcing the launch of Facebook’s Connectivity ...

Samsung Galaxy S3: Connectivity demo - USB OTG, MHL, bluetooth keyboards/mice, games controllers - YouTube ...
AndroidNZ.net - the best source for Galaxy S3 content! For navigation in the video use these links: USB Pendrive @0:55, 500GB portable drive ...

Mid-2012 MacBook Airs offer improved performance and connectivity
Believe it or not, it's been nearly four and a half years since Apple released the original MacBook Air. At the time, it was revolutionary in ...

Connectivity is key in society
They’re billing it as the place where Lewisham meets Summer Hill meets the city – and with good reason.

BMW to launch new connectivity service
Soon your car will notify the dealer when it’s due for a service. BMW Australia will introduce a new suite of in-car connectivity apps in its ...

The key to a successful hybrid cloud infrastructure? Flexible connectivity
It's becoming increasingly clear that - for most organisations - taking a 'hybrid' approach to cloud adoption makes sound business sense.

Facebook Connectivity Lab promotes access to Internet in remote areas - CTV News
Facebook is giving more details about its effort to connect remote parts of the world to the Internet - and it involves drones, lasers and satellites. ...

Resources last updated: 1/7/2016 1:04:45 AM