Click here to Skip to main content
14,971,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to access database from networking sql server so i give the following coding It was not working

SQL
Public con As New SqlConnection("Data Source=SQLSERVER\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=phoneix;User Id=sa;Password=welcome;")
   Public con As New SqlConnection("Data Source=192.170.1.9,1433;Initial Catalog=phoneix;User Id=sa;Password=welcome;")


Please help for this forum

Thanks in Advance
Posted
Updated 6-Jan-12 18:28pm

Check whether you allow remote connection or not.
Allow Remote connection
and then use

C#
<add key=""con"" value=""Data" source="10.11.1.13;Initial" catalog="omx;Persist" security="" info="True;"/"></add>
   
one of the following solution will help you ,

1)Add the sql server port to the connection string:
C#
Server=YourSQLSRVR,10000;Database=YourDatabase;User ID=User;Password=?????????

2)
1. Your SQl Browser is off
2. Protocols under SQLServer Configuration Manager > SQL Server 2005 Network Configuration > Protocols for SQL Express like TCP/IP, Named Pipes are disabled.

Resolution.

Just Start SQL Browser.
Enable the Protocols.
Restart SQL Express service.


3)your pc name\SQLEXPRESS

u copy this name and paste it in the web config file of your asp.net framework as
HTML
<connectionStrings>
<add name="this name is as your wish" connectionString="server=your pc name\\SQLEXPRESS; catalog= your database name;SSPI=true; providerName="System.Data.SqlClient" "/>
</connectionString>
this section comes under <appSettings/>

then u call this string connection in ur aspx.cs code file as
C#
// Create the Connection object.
string connectionString =
WebConfigurationManager.ConnectionStrings["this name is as your wish"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);

then u open the connection and use for your purpose and make sure that u close the connection after use

I hope this might resolve the problem
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900