Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)

Please tell me, when I make a connection with Microsoft SQL Server 2005 which is included in visual studio.

So there is no manager, I just make connection with it by a wizard so it became but i have to work drage and drop from
Data source so I want to work it by coding mean like this:
con = New SqlConnection("server=(LOCALHOST);database=shaan;integrated security=true")


and I want to insert my own command like this:

com = New SqlCommand("insert into table(namee,pass)values('" & Trim(txtuser.Text) & "','" & Trim(txtpass.Text) & "', '" & Date.Now.Day & "/" & Date.Now.Month & "/" & Date.Now.Year & "'", Me.con)
        adpt = New SqlDataAdapter
        adpt.SelectCommand = com
        table = New DataTable
        adpt.Fill(table)
        MsgBox("New Account Created Successfully", MsgBoxStyle.Information, "W E L C O M E")
        Return table


Please tell me somebody...
Posted
Updated 29-Sep-10 8:56am
v4

1 solution

Hi use the same connection string that you get when connected using the wizard, copy and paste the same in the code and try
 
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