Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2009, 01:56 PM
Friend of Wrox
 
Join Date: Mar 2008
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.
 
Old March 9th, 2009, 02:49 PM
Wrox Author
 
Join Date: Oct 2005
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."
===============================================
 
Old March 9th, 2009, 03:59 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
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(); 
}
 
Old March 9th, 2009, 07:19 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old March 11th, 2009, 03:28 AM
Friend of Wrox
 
Join Date: Mar 2008
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.
 
Old March 11th, 2009, 04:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
Old March 11th, 2009, 04:42 PM
Wrox Author
 
Join Date: Oct 2005
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."
===============================================
 
Old March 11th, 2009, 09:40 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old March 12th, 2009, 04:49 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
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(); 
}





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





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