M
Mark Fitzpatrick
Don't use localhost. Try using (local) instead keeping the paranthases ().
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
Justnew said:Hei All
Can some body help me here: I have a database name Customers, I am
trying to connect to SQL server through vb.net using asp.net webform.
I want to connect to the server programatically this is my connection
string:
Private strsql As String
Private strconnection As String = "data source=localhost;initial
catalog=Customers;integrated security=SSPI;persist security
info=False;workstation id=localhost;packet size=4096"
Public Function newCustomer(ByVal Fornavn As String, ByVal Etternavn
As String, ByVal Adresse As String, ByVal PostNr As String, ByVal
PostSted As String, ByVal Telefon As String, ByVal Epost As String,
ByVal Kjønn As String) As String
strsql = "exec NyKunde '" & Fornavn & "','" & Etternavn & "','"
& Adresse & "','" & PostNr & "','" & PostSted & "','" & Telefon & "','"
& Epost & "','" & Kjønn & "'"
Dim conn As SqlConnection = New SqlConnection(strconnection)
conn.Open()
Dim com As SqlCommand = New SqlCommand(strsql, conn)
Try
com.ExecuteNonQuery()
Catch e As SqlException
MsgBox(strsql)
MsgBox(e.ToString)
Throw (e)
Finally
conn.Close()
End Try
End Function
I have use this same method with Windows application, but this does not
seems to work on web application
when I run this application I am getting the following error
Server Error in '/Customers' Application.
-------------------------------------------------------------------------- ------
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does
not exist or access denied.
Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = New
SqlConnection(strconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strsql, conn)
Line 17:
Source File: c:\inetpub\wwwroot\Customers\db.vb Line: 15
Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnec
tionString
options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
Customers.db.RegNyKunde(String Fornavn, String Etternavn, String
Adresse, String PostNr, String PostSted, String Telefon, String Epost,
String Kjønn) in c:\inetpub\wwwroot\Customers\db.vb:15
Customers.WebForm1.leggtilKunde() in
c:\inetpub\wwwroot\Customers\WebForm1.aspx.vb:57
Customers.WebForm1.btnsubmit_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\Customers\WebForm1.aspx.vb:62
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Justnew