473,769 Members | 5,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to get a VB.net sample working with SQL Server.

Hi,

I am trying to get the datacache1 sample working on my PC.
I have downloaded the MSDE 2000 sample SQL Server database and the pubs
sample database and installed it.
I can view the contents of the pubs database.
However, i have trouble connecting to this database from VB.Net

The connection string is:

MyConnection = New
SqlConnection(" server=(local); database=pubs;T rusted_Connecti on=yes")

When i run the sample i get the following error (see below):
This is not surprising as there is no ASPNET user account setup for pubs.

So my question is: How do i configure the pubs database with the correct
user accounts and passwords for the samples to work?

Any help much appreciated.

Also im wondering does microsoft publish a url for telling us how to setup
SQL server for usage with VB.net?

Thanks a lot....John.
Server Error in '/datacache1' Application.
--------------------------------------------------------------------------------

Login failed for user 'WINXP1\ASPNET' .
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: Login failed for user
'WINXP1\ASPNET' .

Source Error:

Line 26:
Line 27: Dim ds As New DataSet
Line 28: myCommand.Fill( ds, "Authors")
Line 29:
Line 30: Source = New DataView(ds.Tab les("Authors"))

Source File: c:\inetpub\wwwr oot\datacache1\ WebForm1.aspx Line: 28


Nov 21 '05 #1
7 3836
Two choices as I see it.

1: add the ASPNET user account to access your database.
2: supply the user and password parameters in your connection string to give
access to a user setup in the database.

Chris

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
Hi,

I am trying to get the datacache1 sample working on my PC.
I have downloaded the MSDE 2000 sample SQL Server database and the pubs
sample database and installed it.
I can view the contents of the pubs database.
However, i have trouble connecting to this database from VB.Net

The connection string is:

MyConnection = New
SqlConnection(" server=(local); database=pubs;T rusted_Connecti on=yes")

When i run the sample i get the following error (see below):
This is not surprising as there is no ASPNET user account setup for pubs.

So my question is: How do i configure the pubs database with the correct
user accounts and passwords for the samples to work?

Any help much appreciated.

Also im wondering does microsoft publish a url for telling us how to setup
SQL server for usage with VB.net?

Thanks a lot....John.
Server Error in '/datacache1' Application.
--------------------------------------------------------------------------------

Login failed for user 'WINXP1\ASPNET' .
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: Login failed for
user
'WINXP1\ASPNET' .

Source Error:

Line 26:
Line 27: Dim ds As New DataSet
Line 28: myCommand.Fill( ds, "Authors")
Line 29:
Line 30: Source = New DataView(ds.Tab les("Authors"))

Source File: c:\inetpub\wwwr oot\datacache1\ WebForm1.aspx Line: 28

Nov 21 '05 #2

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
So my question is: How do i configure the pubs database with the correct
user accounts and passwords for the samples to work?


It is pretty easy if you have SQL Enterprise Manager. If not, then not so
much. :^)

Quick & dirty way: If this is purely for testing on your home box, then just
add the ASPNET user to the local adminsitrator group in Users & Computers.
That will make that user admin for all the databases on your MSDE.

If your have SQL EM that are more appropriate ways of setting this up
correctly. You can even do it using a command prompt and OSQL if you are
feeling so inclined.

HTH,
Greg

Nov 21 '05 #3
Very impressed Greg thanks - that worked a treat!

I had the ASPNET user on my system in the "users" group but not in the
administrators group.

Could you clarify one thing for me....i normally work with oracle ...this is
the first time with SQL Server ....i was thinking
the database connection trying to use the ASPNET user was a DATABASE user
and not a windows XP user account.....whi ch database user account
is used for the SQL Server connection and how does VB.net know the correct
password?

Thanks a lot!

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
So my question is: How do i configure the pubs database with the correct
user accounts and passwords for the samples to work?


It is pretty easy if you have SQL Enterprise Manager. If not, then not so
much. :^)

Quick & dirty way: If this is purely for testing on your home box, then
just add the ASPNET user to the local adminsitrator group in Users &
Computers. That will make that user admin for all the databases on your
MSDE.

If your have SQL EM that are more appropriate ways of setting this up
correctly. You can even do it using a command prompt and OSQL if you are
feeling so inclined.

HTH,
Greg

Nov 21 '05 #4
SQL server can have two types of logins. SQL accounts and Windows accounts.
You can setup SQL to run in mixed mode (SQL and Windows) or Windows only.
(I think MSDE is Windows only by default??)

ASPNET is a windows account.. One correct method of setting up of SQL (if
you have the GUI tools, which MSDE does not come with), is to add the
windows ASPNET user to the server (this allows it to connect to the server,
but with no access to any databases). Next step is to map that windows
account to a SQL login and give it approriate permissions to a database.

As far as your question...

When a ASP.NET page executes, it uses the ASPNET windows identity. (You can
change this in web.config with <identity impersonate="tr ue"/>, but I
wouldn't unless you have a good reason to.). In your connection string you
told it "Trusted_Connec tion=yes" (Note: I've normally seen
"Trusted_Coonec tion=True", or "Integrated Security=SSPI", which both are
equivalent. I've NEVER seen Trusted_Connect ion=yes", but maybe that works
too!?!) That says to connect to the database using the identity of the
current user (which going to be the ASPNET user, since this is a web app).
No need to specify a password, because it is going to use windows
authentication, not SQL authentication.

Make any sense? I am beginning to ramble.

Greg
"John Blair" <jo********@hot mail.com> wrote in message
news:oM******** *******@newsfe6-gui.ntli.net...
Very impressed Greg thanks - that worked a treat!

I had the ASPNET user on my system in the "users" group but not in the
administrators group.

Could you clarify one thing for me....i normally work with oracle ...this
is the first time with SQL Server ....i was thinking
the database connection trying to use the ASPNET user was a DATABASE user
and not a windows XP user account.....whi ch database user account
is used for the SQL Server connection and how does VB.net know the correct
password?

Thanks a lot!

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
So my question is: How do i configure the pubs database with the correct
user accounts and passwords for the samples to work?


It is pretty easy if you have SQL Enterprise Manager. If not, then not
so much. :^)

Quick & dirty way: If this is purely for testing on your home box, then
just add the ASPNET user to the local adminsitrator group in Users &
Computers. That will make that user admin for all the databases on your
MSDE.

If your have SQL EM that are more appropriate ways of setting this up
correctly. You can even do it using a command prompt and OSQL if you are
feeling so inclined.

HTH,
Greg


Nov 21 '05 #5
Greg,

Thanks very much for taking time to reply....SQL Server logon approach is
much clearer thanks!

FYI " Trusted_Connect ion=yes" was taken directly from the online sample
(url below) and works on my win XP PC:

http://samples.gotdotnet.com/quickst...datacache1.src

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:OQ******** ******@TK2MSFTN GP11.phx.gbl...
SQL server can have two types of logins. SQL accounts and Windows
accounts. You can setup SQL to run in mixed mode (SQL and Windows) or
Windows only. (I think MSDE is Windows only by default??)

ASPNET is a windows account.. One correct method of setting up of SQL (if
you have the GUI tools, which MSDE does not come with), is to add the
windows ASPNET user to the server (this allows it to connect to the
server, but with no access to any databases). Next step is to map that
windows account to a SQL login and give it approriate permissions to a
database.

As far as your question...

When a ASP.NET page executes, it uses the ASPNET windows identity. (You
can change this in web.config with <identity impersonate="tr ue"/>, but I
wouldn't unless you have a good reason to.). In your connection string
you told it "Trusted_Connec tion=yes" (Note: I've normally seen
"Trusted_Coonec tion=True", or "Integrated Security=SSPI", which both are
equivalent. I've NEVER seen Trusted_Connect ion=yes", but maybe that works
too!?!) That says to connect to the database using the identity of the
current user (which going to be the ASPNET user, since this is a web app).
No need to specify a password, because it is going to use windows
authentication, not SQL authentication.

Make any sense? I am beginning to ramble.

Greg
"John Blair" <jo********@hot mail.com> wrote in message
news:oM******** *******@newsfe6-gui.ntli.net...
Very impressed Greg thanks - that worked a treat!

I had the ASPNET user on my system in the "users" group but not in the
administrators group.

Could you clarify one thing for me....i normally work with oracle ...this
is the first time with SQL Server ....i was thinking
the database connection trying to use the ASPNET user was a DATABASE user
and not a windows XP user account.....whi ch database user account
is used for the SQL Server connection and how does VB.net know the
correct password?

Thanks a lot!

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
So my question is: How do i configure the pubs database with the
correct
user accounts and passwords for the samples to work?

It is pretty easy if you have SQL Enterprise Manager. If not, then not
so much. :^)

Quick & dirty way: If this is purely for testing on your home box, then
just add the ASPNET user to the local adminsitrator group in Users &
Computers. That will make that user admin for all the databases on your
MSDE.

If your have SQL EM that are more appropriate ways of setting this up
correctly. You can even do it using a command prompt and OSQL if you
are feeling so inclined.

HTH,
Greg



Nov 21 '05 #6
A quick search on google and I see Trusted_Connect ion=yes is pretty commonly
used. One of my ADO.NET books talks about all the these different valid
variations. I'll have to look it up later tonight.

Greg
"John Blair" <jo********@hot mail.com> wrote in message
news:Zt******** ********@newsfe 6-gui.ntli.net...
Greg,

Thanks very much for taking time to reply....SQL Server logon approach is
much clearer thanks!

FYI " Trusted_Connect ion=yes" was taken directly from the online sample
(url below) and works on my win XP PC:

http://samples.gotdotnet.com/quickst...datacache1.src

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:OQ******** ******@TK2MSFTN GP11.phx.gbl...
SQL server can have two types of logins. SQL accounts and Windows
accounts. You can setup SQL to run in mixed mode (SQL and Windows) or
Windows only. (I think MSDE is Windows only by default??)

ASPNET is a windows account.. One correct method of setting up of SQL
(if you have the GUI tools, which MSDE does not come with), is to add the
windows ASPNET user to the server (this allows it to connect to the
server, but with no access to any databases). Next step is to map that
windows account to a SQL login and give it approriate permissions to a
database.

As far as your question...

When a ASP.NET page executes, it uses the ASPNET windows identity. (You
can change this in web.config with <identity impersonate="tr ue"/>, but I
wouldn't unless you have a good reason to.). In your connection string
you told it "Trusted_Connec tion=yes" (Note: I've normally seen
"Trusted_Coonec tion=True", or "Integrated Security=SSPI", which both are
equivalent. I've NEVER seen Trusted_Connect ion=yes", but maybe that
works too!?!) That says to connect to the database using the identity of
the current user (which going to be the ASPNET user, since this is a web
app). No need to specify a password, because it is going to use windows
authentication, not SQL authentication.

Make any sense? I am beginning to ramble.

Greg
"John Blair" <jo********@hot mail.com> wrote in message
news:oM******** *******@newsfe6-gui.ntli.net...
Very impressed Greg thanks - that worked a treat!

I had the ASPNET user on my system in the "users" group but not in the
administrators group.

Could you clarify one thing for me....i normally work with oracle
...this is the first time with SQL Server ....i was thinking
the database connection trying to use the ASPNET user was a DATABASE
user and not a windows XP user account.....whi ch database user account
is used for the SQL Server connection and how does VB.net know the
correct password?

Thanks a lot!

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...

"John Blair" <jo********@hot mail.com> wrote in message
news:yG******** *****@newsfe5-gui.ntli.net...
> So my question is: How do i configure the pubs database with the
> correct
> user accounts and passwords for the samples to work?

It is pretty easy if you have SQL Enterprise Manager. If not, then not
so much. :^)

Quick & dirty way: If this is purely for testing on your home box, then
just add the ASPNET user to the local adminsitrator group in Users &
Computers. That will make that user admin for all the databases on your
MSDE.

If your have SQL EM that are more appropriate ways of setting this up
correctly. You can even do it using a command prompt and OSQL if you
are feeling so inclined.

HTH,
Greg




Nov 21 '05 #7
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
A quick search on google and I see Trusted_Connect ion=yes is pretty
commonly used. One of my ADO.NET books talks about all the these different
valid variations. I'll have to look it up later tonight.

Greg


From "ADO.NET Example of Best Practices for C# Programmers" (p.50)

Note: When setting Boolean properties (in connection string), you can use
'yes' instead of 'true', and 'no' instead of 'false'.

That clears that up. :)

Greg
Nov 21 '05 #8

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

Similar topics

6
1727
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry, this is a local page, not one on the Internet). I had it working fine with row-returning SQL, such as SELECT, but was trying to get it to work with non-row-returnign ones as well (such as UPDATE and DELETE). Not only can't I get this bit to work, I...
6
3146
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something like http://myserver/mypage.aspx. From there it gets blurry, because I just can't figure out how to do the rest. Does anybody have a sample page for me that I can take a look at? Just a simple one that takes whatever biztalk sends and saves it...
4
6286
by: Joey | last post by:
Does anyone know how to center this sample webpage in Firefox? If so, will you provide the example as it applies to this sample webpage? I have read numerous posts and articles on how to center content with CSS...none are working for me. The best I can do at this point is the "text-align: center" for my div tag, but that only works in IE. I want to be able to center all the content within the div (effectively center the site content) for...
2
5715
by: jason | last post by:
hello. i am just trying to save a TextBox.Text value to a database, but strangely, when the value is changed on the web form, the changes are not recognized in the event where i try to save the information. sample.aspx contents: <form id="Form1" method="post" runat="server"> <asp:TextBox id="TextBox1" runat="server" Width="560px" Height="512px" Wrap="True" TextMode="MultiLine"> </asp:TextBox>
14
5907
by: dba_222 | last post by:
Dear experts, Again, sorry to bother you again with such a seemingly dumb question, but I'm having some really mysterious results here. ie. Create procedure the_test As
5
2351
by: Will | last post by:
- I know enough ASP and Access to be dangerous :) - I need to put up a data base on our web server with 3 related tables. - They will be accessed by a limited number of people. - Each user will have to "log on" with a username and password and only have access to their records. - Their will be a main table with two associated tables... - This is not the application but it is simmilar in structure... Example:
5
16135
by: Otto Wyss | last post by:
I've now been looking for a week for a simple but useful sample on how to get a list of entries (persons) via an XMLHttpRequest using Json/PHP on the server. So far I've found about a thousend different tutorials and code samples but not a single one, where the server returns an array of entries. Very few samples use Json at all and almost none show the server code. So does anybody know a sample which - uses just a small javascript...
3
2669
by: Ciaran Byrne | last post by:
I'm trying to move data from one or more tables to identical table(s) in a different database, likely on a different server. This prevents me from using INSERT..SELECT, so up until now I've done a select on the source table and looped through the results inserting them individually into the target table. I thought that a prepared statement might improve the performance, but I can't get it to work. Below is some sample code, and I imagine...
6
1728
by: The Natural Philosopher | last post by:
I am trying to create what amounts to an array of 'structures'. I.e. I want to dynamically add to and access an object as myobject.anothernumber // actually represents a nesting level. and myobject.elementintheDOM // this is a pointer to //store particular elements..i.e.
0
9589
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
10215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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,...
1
7410
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
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
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
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.