Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi how can i solve this error in connect to sql to create a database or add data to database:
i install sqlexpress with dotnet


ASM
A network-related or instance-specific error occurred
while

establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)


!!!!!!!!my sql server is good work
because when i and drag a sqldatasource to my page and related a datagrid with it
my database work good

i used this code for create db
C#
{
  string strsql, strcon;
        strcon = "Data Source=(1-pc);Initial Catalog=neww.mdf;Integrated Security=true";
        SqlConnection con = new SqlConnection(strcon);
        SqlCommand cmdclasf;
        strsql = "create database product";
        con.Open();
        cmdclasf = new SqlCommand(strsql, con);
        int count = cmdclasf.ExecuteNonQuery();
        con.Close();
        if (count == 0)
            Label1.Text = "not create";
        else
            Label1.Text = "created";
}
Posted
Updated 21-May-12 18:48pm
v5

Hi friends,

Check ur connection string properly....

it is from ur connection string...

if the data source is from network, then check the network server is running or not.
 
Share this answer
 
 
Share this answer
 
Hi ,
To get the right ConnectionString you can use UDL
Check this link
http://www.gotknowhow.com/articles/test-a-database-connection-string-using-notepad[^]
Best Regards
M.Mitwalli
 
Share this answer
 
this is a connection string problem with your sqlexpress

what server and credintials you use to connect explain
 
Share this answer
 

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