473,808 Members | 2,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=localhos t;initia
catalog=Custome rs;integrated security=SSPI;p ersist securit
info=False;work station id=localhost;pa cket size=4096"

Public Function newCustomer(ByV al 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(s trconnection)
conn.Open()
Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Try
com.ExecuteNonQ uery()
Catch e As SqlException
MsgBox(strsql)
MsgBox(e.ToStri ng)
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.Sql Client.SqlExcep tion: SQL Server doe
not exist or access denied.

Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = Ne
SqlConnection(s trconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Line 17:
Source File: c:\inetpub\wwwr oot\Customers\d b.vb Line: 15

Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean
isInTransaction )

System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionStrin
options, Boolean& isInTransaction )
System.Data.Sql Client.SqlConne ction.Open()
Customers.db.Re gNyKunde(String Fornavn, String Etternavn, Strin
Adresse, String PostNr, String PostSted, String Telefon, String Epost
String Kjønn) in c:\inetpub\wwwr oot\Customers\d b.vb:15
Customers.WebFo rm1.leggtilKund e() i
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :57
Customers.WebFo rm1.btnsubmit_C lick(Object sender, EventArgs e) i
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :62
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St rin
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandle
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain(

Justne
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.htm

Nov 18 '05 #1
3 1632
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=localhos t;initial
catalog=Custome rs;integrated security=SSPI;p ersist security
info=False;work station id=localhost;pa cket size=4096"

Public Function newCustomer(ByV al 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(s trconnection)
conn.Open()
Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Try
com.ExecuteNonQ uery()
Catch e As SqlException
MsgBox(strsql)
MsgBox(e.ToStri ng)
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.Sql Client.SqlExcep tion: SQL Server does
not exist or access denied.

Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = New
SqlConnection(s trconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Line 17:
Source File: c:\inetpub\wwwr oot\Customers\d b.vb Line: 15

Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )

System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne c
tionString options, Boolean& isInTransaction )
System.Data.Sql Client.SqlConne ction.Open()
Customers.db.Re gNyKunde(String Fornavn, String Etternavn, String
Adresse, String PostNr, String PostSted, String Telefon, String Epost,
String Kjønn) in c:\inetpub\wwwr oot\Customers\d b.vb:15
Customers.WebFo rm1.leggtilKund e() in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :57
Customers.WebFo rm1.btnsubmit_C lick(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :62
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
Justnew
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message346156.html

Nov 18 '05 #2
try this connectionstrin g

"SERVER=localho st;DATABASE=Cus tomers;Integrat ed Security=SSPI;p ersist
security info=False;pack et 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=localhos t;initial
catalog=Custome rs;integrated security=SSPI;p ersist security
info=False;work station id=localhost;pa cket size=4096"

Public Function newCustomer(ByV al 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(s trconnection)
conn.Open()
Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Try
com.ExecuteNonQ uery()
Catch e As SqlException
MsgBox(strsql)
MsgBox(e.ToStri ng)
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.Sql Client.SqlExcep tion: SQL Server does
not exist or access denied.

Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = New
SqlConnection(s trconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Line 17:
Source File: c:\inetpub\wwwr oot\Customers\d b.vb Line: 15

Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )

System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne c
tionString options, Boolean& isInTransaction )
System.Data.Sql Client.SqlConne ction.Open()
Customers.db.Re gNyKunde(String Fornavn, String Etternavn, String
Adresse, String PostNr, String PostSted, String Telefon, String Epost,
String Kjønn) in c:\inetpub\wwwr oot\Customers\d b.vb:15
Customers.WebFo rm1.leggtilKund e() in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :57
Customers.WebFo rm1.btnsubmit_C lick(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :62
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
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\NETWO RK 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.Sql Client.SqlExcep tion: Login failed fo
user 'NT AUTHORITY\NETWO RK SERVICE'.

Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = Ne
SqlConnection(s trconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Line 17:
Source File: c:\inetpub\wwwr oot\Customers\d b.vb Line: 15

Stack Trace:
[SqlException: Login failed for user 'NT AUTHORITY\NETWO RK SERVICE'.]
System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean
isInTransaction )

System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionStrin
options, Boolean& isInTransaction )
System.Data.Sql Client.SqlConne ction.Open()
Customers.db.Re gNyKunde(String Fornavn, String Etternavn, Strin
Adresse, String PostNr, String PostSted, String Telefon, String Epost
String Kjønn) in c:\inetpub\wwwr oot\Customers\d b.vb:15
Customers.WebFo rm1.leggtilKund e() i
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :57
Customers.WebFo rm1.btnsubmit_C lick(Object sender, EventArgs e) i
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :62
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St rin
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandle
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain


Michael Ramey wrote:
*try this connectionstrin g

"SERVER=localho st;DATABASE=Cus tomers;Integrat e
Security=SSPI;p ersist
security info=False;pack et 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=localhos t;initial
catalog=Custome rs;integrated security=SSPI;p ersist security
info=False;work station id=localhost;pa cket size=4096"

Public Function newCustomer(ByV al 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(s trconnection)
conn.Open()
Dim com As SqlCommand = New SqlCommand(strs ql, conn)
Try
com.ExecuteNonQ uery()
Catch e As SqlException
MsgBox(strsql)
MsgBox(e.ToStri ng)
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.Sql Client.SqlExcep tion: SQL Server

does
not exist or access denied.

Source Error:
Line 13:
Line 14: Dim conn As SqlConnection = New
SqlConnection(s trconnection)
Line 15: conn.Open()
Line 16: Dim com As SqlCommand = New SqlCommand(strs ql,

conn)
Line 17:
Source File: c:\inetpub\wwwr oot\Customers\d b.vb Line: 15

Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )

System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne c
tionString
options, Boolean& isInTransaction )
System.Data.Sql Client.SqlConne ction.Open()
Customers.db.Re gNyKunde(String Fornavn, String Etternavn, String
Adresse, String PostNr, String PostSted, String Telefon, String

Epost,
String Kjønn) in c:\inetpub\wwwr oot\Customers\d b.vb:15
Customers.WebFo rm1.leggtilKund e() in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :57
Customers.WebFo rm1.btnsubmit_C lick(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\Customers\W ebForm1.aspx.vb :62
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection

postData)
System.Web.UI.P age.ProcessRequ estMain()
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
2446
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 Manager. Your main application then hooks into the Plugin Manager. What I'm trying to figure out is how to impliment some form of raising
5
1355
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! //----------------------------------------------------------------------- //Wrote by Michael April 30 2005 //----------------------------------------------------------------------- using System.Text;
7
2131
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 have write access to my web root folder, I have a folder specialy for database. I am currently using access, it is just for testing purpose. here's the info:
6
1414
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, I would like to "include" them, or "import", say an ascx file. In ASP, all you needed to to was include another .asp file to do this. Many thanks, Chad
6
1512
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 server running Win2K, which serves as Web Server and SQL server as well. And, since my hosting (production server) using the same config; ie: using a single server to serve both web server and SQL server; it's always been easy
15
4651
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
3
1377
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 (comma delimited) into a dataset. My problem is that the connection object I have used in the past seems to be outdated: I want to use the System.Data.SQLClient exclusively without any OLE objects but cannot find the required connection...
13
5806
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 CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge table. No data is being entered into the bridge table.
6
2988
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 them. to be more clear we process this purpose we serve this to the student in the university. how?? student will send a message that contains his name,id and request by format the server want such as zaina-20024008-grade. the grade is the request...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9196
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.