anyone can help with sql connection problems
hi guys, :)
i am very happy that i found this forum which discuss ASP.net.
i am new to ASP.net 2.0 and need some serious help. when i debug my application and try to insert data an error occur saying:
"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)"
the code that i have used to submit data is as follow:
Imports System.Data.SqlClient
...
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
objconn = New SqlConnection("Server=localhost; Database=ecb;user
ID='';Password=''")
objCmd = New SqlCommand("INSERT INTO staff (firstname, surname) VALUES (@firstname, @surname,)", objConn)
objCmd.Parameters.Add("@FirstName", Data.SqlDbType.VarChar).Value = txtFirstName.Text
objCmd.Parameters.Add("@Surname", Data.SqlDbType.VarChar).Value = txtSurname.Text
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
can anyone help? thank you in advanced
|