Hei All
Can some body help me here: I have a database name Customers, I a
trying to connect to SQL server through vb.net using asp.net webform.
I want to connect to the server programatically this is my connectio
string:
Private strsql As String
Private strconnection As String = "data source=localhost;initia
catalog=Customers;integrated security=SSPI;persist securit
info=False;workstation id=localhost;packet size=4096"
Public Function newCustomer(ByVal Fornavn As String, ByVal Etternav
As String, ByVal Adresse As String, ByVal PostNr As String, ByVa
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 no
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 o
the current web request. Please review the stack trace for mor
information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server doe
not exist or access denied.
Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = Ne
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.Get PooledConnection(SqlConnectionStrin
options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
Customers.db.RegNyKunde(String Fornavn, String Etternavn, Strin
Adresse, String PostNr, String PostSted, String Telefon, String Epost
String Kjønn) in c:\inetpub\wwwroot\Customers\db.vb:15
Customers.WebForm1.leggtilKunde() i
c:\inetpub\wwwroot\Customers\WebForm1.aspx.vb:57
Customers.WebForm1.btnsubmit_Click(Object sender, EventArgs e) i
c:\inetpub\wwwroot\Customers\WebForm1.aspx.vb:62
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(Strin
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandle
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain(
Justne
-----------------------------------------------------------------------
Posted via
http://www.mcse.m
-----------------------------------------------------------------------
View this thread:
http://www.mcse.ms/message346156.htm