Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2009, 01:56 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default Making the Page_Load() work

okay so my page load for my profile page is supposedly planned as:

1) (on the first time run only) Open a connection to my database and add a table to it.

2) Comment out table creation code

3) add code to check the table for new messages for the signed in user

4) Get the number of these messages and display them in a link saying "{0} new messages"

thats it so far... im stuck on step one:

here is my code, its the first thing in Page_Load()

Code:
 
// One time use: create database table:
string con = WebConfigurationManager.ConnectionStrings["myconnection"].ConnectionString;
SqlConnection sqlcon = newSqlConnection(con);
SqlCommand cmd = newSqlCommand("CREATE TABLE Messages(Id Int Identity(1,1), Sender NVarChar(11), Recievers NVarChar, MessageBody NVarChar(1500), MessageSubject NVarChar(25), status Int");
cmd.Connection = sqlcon;
using (sqlcon)
{
sqlcon.Open();
cmd.ExecuteNonQuery();
sqlcon.Close();
}
now when i run this code... it complains that i dont have permission to do this.
  #2 (permalink)  
Old March 9th, 2009, 02:49 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

We talked about this outside of the boards so i wont rehash the convo. The simple answer is that the account that you use to access SQL server is probably only a datareader/writer which means it can read and write data to and from the database. This is a security meause since you dont want to expose powerful sql commands to the general populace.

You will need to talk to your host about the best way to proceed.
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #3 (permalink)  
Old March 9th, 2009, 03:59 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

What is the security message exactly?

I can think of two things that could be happening.

First, I have heard of hosters who run in medium trust not allowing access to WebConfigurationManager. Weird, I know, but it does happen. The workaround for this is usually to use ConfigurationManager instead.

Second, the ASP.NET worker process doesn't have permission to run DDL commands. This is probably more likely. Like Doug said, you'll have to see if you can grant dbo permissions to the ASP.NET account.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #4 (permalink)  
Old March 9th, 2009, 07:19 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

thanks guys
  #5 (permalink)  
Old March 11th, 2009, 03:28 AM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

here is their process: upload db file to db folder,

attach db file... when you need to update the db file, detach and re upload. and attach again...

sounds fun... so... yeah i had to work out some things like adding two connection strings in the web.config, one for developing on my local pc and the other for the website. I have to use SQL Management studio to do execute the queries. that doesnt seem like an issue to me... i got kind of a feel for that program now.

anyways this was a fun mini-adventure :) whats cool about knowing nothing due to my experience level is that i can learn stuff every day. haha.
  #6 (permalink)  
Old March 11th, 2009, 04:12 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
whats cool about knowing nothing due to my experience level is that i can learn stuff every day.
I don't think that newbies have that exclusive right.... ;-) I think it applies to all of us. I know it does to me.....

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #7 (permalink)  
Old March 11th, 2009, 04:42 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Quote:
Originally Posted by Imar View Post
I think it applies to all of us. I know it does to me.....
Agreed! =]

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #8 (permalink)  
Old March 11th, 2009, 09:40 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

true... nobody knows everything.

but the people with 10k+ forum points hide that fact pretty well. haha

i never hear an "idk" from those guys.. i might hear "google it" but thats because a lot of my questions are asked out of laziness. and i think people like me should get used to googling the error messages before asking someone what they should do.. i mean the answer can be found as quickly as if someone gave it to you in some cases.

talk about an off topic post haha
  #9 (permalink)  
Old March 12th, 2009, 04:49 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by iceman90289 View Post
anyways this was a fun mini-adventure :) whats cool about knowing nothing due to my experience level is that i can learn stuff every day. haha.
Hey, don't think for a minute that the 10K+ guys don't struggle with stuff every day, same as you do.

Experience doesn't just mean you know more stuff. It means that you have learned how to learn the stuff you don't know.

That means reading code better, navigating through the MSDN better, knowing how to ask better questions, and so on...
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making serial comm work with SerialPort GMan Visual Basic 2008 Essentials 3 March 7th, 2008 05:32 AM
making special characters work Brian Campbell XSLT 4 January 10th, 2007 03:43 PM
Adding Page_Load to base class doesn't work Raeldor BOOK: ASP.NET Website Programming Problem-Design-Solution 2 September 24th, 2004 06:30 AM
making php work? P.Y.sum Beginning PHP 5 November 5th, 2003 10:28 AM
making an .exe work cooky4 VB Databases Basics 2 June 3rd, 2003 11:31 PM



All times are GMT -4. The time now is 08:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.