473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Need Help connection String


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

Nov 18 '05 #1
3 1611
Don't use localhost. Try using (local) instead keeping the paranthases ().

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Justnew" <Ju************@mail.mcse.ms> wrote in message
news:Ju************@mail.mcse.ms...

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.Get PooledConnection(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.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Justnew
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.html

Nov 18 '05 #2
try this connectionstring

"SERVER=localhost;DATABASE=Customers;Integrate d Security=SSPI;persist
security info=False;packet size=4096"

Also, where is the SQL Server you are trying to connect to?

I hope it is local on the machine you are running this code from
"localhost", and I hope it doesn't have an instance name. If it is local,
open the Service Manager in your system tray, and replace localhost with
whatever is says in the "Server" field

HTH,
--Michael

"Justnew" <Ju************@mail.mcse.ms> wrote in message
news:Ju************@mail.mcse.ms...

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.Get PooledConnection(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.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Justnew
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.html

Nov 18 '05 #3

Thank you for the reply I have replace the instance name as exactly a
it is in the service manager, now when I tried to run the applicatio
this error Iam receiving. I have used mix mode in the authention

Server Error in '/Customers' Application.
--------------------------------------------------------------------------------

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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: Login failed fo
user 'NT AUTHORITY\NETWORK SERVICE'.

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: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
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


Michael Ramey wrote:
*try this connectionstring

"SERVER=localhost;DATABASE=Customers;Integrate
Security=SSPI;persist
security info=False;packet size=4096"

Also, where is the SQL Server you are trying to connect to?

I hope it is local on the machine you are running this code from
"localhost", and I hope it doesn't have an instance name. If it i
local,
open the Service Manager in your system tray, and replace localhos
with
whatever is says in the "Server" field

HTH,
--Michael

"Justnew" <Ju************@mail.mcse.ms> wrote in message
news:Ju************@mail.mcse.ms...

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.ne

webform.
I want to connect to the server programatically this is m

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, ByVa

Etternavn
As String, ByVal Adresse As String, ByVal PostNr As String, ByVal
PostSted As String, ByVal Telefon As String, ByVal Epost A

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 doe

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.Get PooledConnection(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.IPo stBackEventHandler.RaisePo
stBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection

postData)
System.Web.UI.Page.ProcessRequestMain()
Justnew

------------------------------------------------------------------------
Posted via http://www.mcse.ms

------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.html
*

Justnew
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.html

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin...
5
by: roopeman | last post by:
i wrote the below code , just want got local machine application Eventlog 's message , and write to MDB.but it 's can not write the message to Mdb, somebody can check it for me? thanks! ...
7
by: Tee | last post by:
Hi, I need some help here for DSN connection string. I know it's not recommended to use DSN, even I dont like it as well ... but for now, my situation is I am using a shared hosting. I do not...
6
by: Chad A. Beckner | last post by:
Does anyone know how to make common database connections "common" in all aspx files? In other words, instead of creating a SQLConnection, then a DataAdapter in every ASPX file for my application,...
6
by: Mike L. | last post by:
Hi, Pls, beware that I'm new to this :) I've developed several web appl, either with ASP or ASP.NET. All using SQL server as the back end. In my development environment, I have a single...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
by: thejamie | last post by:
My question: "What is the correct connection object to use in VS 2005 for a text connection?" will need some background. I am placing code at the end showing how I am reading data from a text file...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
6
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.