Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Saturday, March 31, 2012

The ASPNET Sql Server Account

What's the proper way to setup this account in SQL Server?

We're using Windows authentication on our network and to give any user permission in the database I have to grant it to the ASPNET account. This seems to defeat the purpose of using Windows authentication because anyone that opens the ASP.NET page will have those rights in the database even if they aren't listed as a user in the DB.

For example, I give read-only rights to the ASPNET account and even if I give an individual user db_datawriter rights, they still cannot write to the DB unless I grant the ASPNET account db_datawriter rights. Then anyone can save/modify the data.Is SQL server installed on the same machine as IIS?

This will have an impace on how the ASPNET user operates.
Both are on the same machine.
set impersonation on in the web config file

<impersonate=true/>

Or something to that affect...
This is a good article on the microsoft site, it explains the different methods for accessing SQL server.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconaccessingsqlserverfromwebapplication.asp

This is also a good article.
http://support.microsoft.com/default.aspx?scid=kb;en-us;815154
Originally posted by hellswraith
set impersonation on in the web config file

<impersonate=true/>

Or something to that affect...

that did the trick. well actually it was

<identity impersonate="true" />

then you can get rid of the ASPNET account if using Windows authentication.
Does anyone know if this impersonate would work if IIS and SQL server are on different machines.
I have a feeling it won't but I am happy to be told I am wrong.
I'm pretty sure they have to be on the same machine. I think I read that on MSDN.
That was my understanding. The first article in on of my previous posts talks about it.
Sometimes I wonder if I understand it the way they mean it.
From my interpretation of the article, You need to have the SQL Server and IIS (web server) on the same machine if you want to use Windows authentication OR anonymous access with the ASPNET account.

If you want to access the SQL Server using a Mapped Windows Domain User or prompting for the username and password and passing them as credentials then you don't need the SQL Server and web server on the same machine.
I went on ASP.NET training last week where IIS and SQL were on the same server, the ASPNET account was used.
We came away thinking that is how it naturally worked. It took me half a day and some searching to find out it wasn't so cut and dried.

The best file format to import/export data into sql database through asp.net application

Hi,

We are developing a SQL server based asp.net application. As part of
requirement we should allow users import/export some relational data through
web user interface. We are investigation which file format would be the most
efficient format to import export relational data.

So far we came up with two options: XML and Access MDB files and we prefer
MDB files.

Is there any better file format for import/export data?

Any help would be appreciated,
MaxThe format is not part of the requirements ? What is the exact purpose ?

IMO users are more used to spreadsheet files rather than to xml or even
Access files. Of course it depends if the overall goal is to import/export
data to automated systems or if this is to allows users to handle those
files by themselves in a familiar tool...

My personal default preference would be likely Excel files but your berst
bet is liekly to ask them what they intend to do with those files...

--
Patrice

"Max2006" <alanalan1@dotnet.itags.org.newsgroup.nospama crit dans le message de news:
OtaUPQpCIHA.464@dotnet.itags.org.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
We are developing a SQL server based asp.net application. As part of
requirement we should allow users import/export some relational data
through web user interface. We are investigation which file format would
be the most efficient format to import export relational data.
>
So far we came up with two options: XML and Access MDB files and we prefer
MDB files.
>
Is there any better file format for import/export data?
>
Any help would be appreciated,
Max
>
>
>


CSV is what I would pick.

"Max2006" <alanalan1@dotnet.itags.org.newsgroup.nospamwrote in message
news:OtaUPQpCIHA.464@dotnet.itags.org.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
We are developing a SQL server based asp.net application. As part of
requirement we should allow users import/export some relational data
through web user interface. We are investigation which file format would
be the most efficient format to import export relational data.
>
So far we came up with two options: XML and Access MDB files and we prefer
MDB files.
>
Is there any better file format for import/export data?
>
Any help would be appreciated,
Max
>
>
>


I see nothing wrong with MDB as asp.net has a data provider for it. You can
read it directly into SQL Server using dataset, I would think.

David
"Max2006" <alanalan1@dotnet.itags.org.newsgroup.nospamwrote in message
news:OtaUPQpCIHA.464@dotnet.itags.org.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
We are developing a SQL server based asp.net application. As part of
requirement we should allow users import/export some relational data
through web user interface. We are investigation which file format would
be the most efficient format to import export relational data.
>
So far we came up with two options: XML and Access MDB files and we prefer
MDB files.
>
Is there any better file format for import/export data?
>
Any help would be appreciated,
Max
>
>
>


CSV (Comma Separated Values) is generally considered to be the most
platform-agnostic file format.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Max2006" wrote:

Quote:

Originally Posted by

Hi,
>
We are developing a SQL server based asp.net application. As part of
requirement we should allow users import/export some relational data through
web user interface. We are investigation which file format would be the most
efficient format to import export relational data.
>
So far we came up with two options: XML and Access MDB files and we prefer
MDB files.
>
Is there any better file format for import/export data?
>
Any help would be appreciated,
Max
>
>
>
>

Wednesday, March 28, 2012

The big hole in .Net - Reporting

OK - So you've written a killer invoicing application in ASP.Net using SQL Server as a data store.

Your database works a treat, the user interface looks great on screen and then your customer spoils it all by asking - "how do I print an invoice" ?

Mmmm - never thought about that !

Well, I'm just a dumb developer who has been writing Windows app's for 10 years and is used to easily creating all the reports once the main application is working.

What is Microsoft's excuse ?

Why is there no reporting capability for ASP.Net ?

Their "partners" who have just such a product to fill the gap, must be raking it in - especially as they all provide a license on a per server basis !

I'd like to know how other developers are currently reporting and printing from their ASP.Net applications and if any improvements are planned for the next version.

Steve.Crystal Reports is included with VS.NET, if you have that. That's the reporting solution. You can also use Microsoft's SQL Server Reporting Services, a free add-on to SQL Server 2000.

Or you could create a PDF file from the server with it. Or you could just have them print the Web page (admittedly this is less than desireable).

Lots of options. Any of these work?
Don
Well, actually MS just release SQL Reporting Services that is based on the .NET framework, and can be expanded using .NET.
Don,

Thanks for the suggestions.

Some time ago, I wasted several hours and could not even get a connection to SQL Server from Crystal Reports. I wasted many more hours trying other things with it. Some of my applications ship to customers to run on their intranets and I would not want them to go anywhere near Crystal Reports. There is also very little support - unless you flash the cash of course !

I have been looking at PDF writers for over 12 months in the hope that one will appear where you do not need a license for each server. I have still not found any.

I am not familiar with the SQL Server Reporting add on - can you point me in the right direction as I would be very interested to find out more.

Matt,

Sounds good - where can I find out more.

Steve.
Steve,

i'm using ActiveReports.NET to generate Reports as HTML Pages, Excel Sheets and PDF's within my web site. It works well and it is easy to use. You can download a trial version at

Data Dynamics

Tom
Thanks Tom,

I've been considering Active Reports. Would I be able to design an invoice report and ensure that it prints out exactly as required - regardless of the users browser or screen resolution ?

Steve.
I use ActiveReports. Very easy, extendible, and affordable.
You have several options, but usually you would generate PDFs,
which do print exactly as required, regardless of browser, etc.
You can find SQL Reporting Services at http://www.microsoft.com/sql/reporting
I wrote a small vb.net windows app which is using the crystal report components integreated in VS.net. I had to create a setup project and put in the licence keys. Now it works perfect on the machine I installed the app.

So I think it's very easy to use Crystal Reports. You can do the same with webprojects and generate pdf's there.

Just an idea ...
Many of my clients use MSDE. When asked if MSDE is supported - the FAQ from SQL Server Reporting states...

"Although Reporting Services can use data from MSDE databases, the Report Server Database cannot be stored in an instance of MSDE."

I'm not too sure if that's a Yes or a No ?

Can anyone expand on that ?

Thanks for the other suggestions - I'm looking into those too.

Steve.
I might be missing something here, and I'd like one of the ActiveReports users to correct me if I'm wrong, but...

I use Crystal Reports. I'm a big fan of the product froma development point-of-view, but have always hated it from a deployment perspective.

That said, at $9,000 + for each per-site license of the professional edition of Active Reports, what exactly am I getting that the 'free', out-of-the-box .net edition of CR doesn't already give me? With a few lines of code, I can export to pdf. I can do HTML reports. I can export effortlessly to word and excel and RTF.

Trust me, I'm not an avid CR defender; I'm really just curious here...
Well, I would start by reading the license for the "free" Crystal Reports edition.
Note that I'm not a reader of "legalese" either, but people I work with do read it,
and I can assure you many places pay a heck of a lot more than $9000 for CR.
Its also a question of you get what you pay for -- CR just sucks most of the time.
Well, we'll have to agree to disagree on that last point. I think that there is real value in CR< though the support sucks.

But I've implemented numerous site with the CR that comes bundled with enterprise edition. And I didn't see anything that suggested to me that Active Reports offers anything above and beyond. What are the features that it offers that make it a solid alternative to CR?
By the sounds of it - I think that licensing seems to be the key issue as both CR and Active Reports are very powerful products.

The problem I have with CR (other than not being able to get it to work) is that they have given very little in the free version for developers requiring a runtime-free product. They have "dangled a carrot" by getting it bundled with Visual Studio.Net - but it's really not worth taking a bite.

A $9,000 licence fee may be acceptable for large projects, but unfortunately, I rely on selling ASP.Net applications to smaller companies - at a lot less than $9K a go !

Looks like Active Reports is favourite for me.

By the way - don't Microsoft own Crystal anyway ? - that would explain a lot.

Steve.
Well that is my point. For the Professional Version of Active Reports, at least according to the website, you'll be paying that $9,000 per site liscensing fee. And given that, I wonder just what it has and does that Crystal doesn't...

Monday, March 26, 2012

The conversion of a char data type to a datetime data type resulted in an out-of-range dat

getting this error - i think its because im trying to put english date
format into american date format
(asp to sql server 2000)

im getting the date using
mortsourcedlabel.Text = Date.Today
mortsourcedlabel.Visible = True
mortsourced.Visible = False

which throws the date out (in uk format) to 13/02/2004 - all well and good
but -
im assuming that its going out of range as sql needs 02/13/2004
heh im guessing ive been testing code the past 2 weeks -- and now its the
13th which has now thrown up the error!
how do i change the date format not in the code above (i still need to see
the date in english-UK format on the page) but before the sql statement
(maybe in my stored procedure?)
thanks

marknm i sussed it with :-

Dim msl As String = mortsourcedlabel.Text.ToString ' date
Dim day, month, year As String
If mortsourcedlabel.Text.ToString = "" Then
msl = "01/01/1900"
Else
Dim mydate As Date
mydate = mortsourcedlabel.Text.ToString
day = mydate.Day.ToString
month = mydate.Month.ToString
year = mydate.Year.ToString
msl = month + "/" + day + "/" + year
End If

cheers

mark

The conversion of a char data type to a datetime data type resulted....

Hi,

I'm trying to insert a date time value into a SQL Server Database field of type date time using a c# web form.
I get the following error...
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated"

My SQL looks like this:


INSERT INTO tblname (fldname) VALUES ('" + DateTime.Now.ToString() + "')"

What am I doing wrong?Remove the ToString() method as that is changing the DateTime type to a string (or Char type) ...at least thats what it looks like.
Nope sorry to say that didn't work.

My C# now looks like


SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["eTeam_ConnectionString"].ToString());
string mySQL = "INSERT INTO tblname (datestamp) VALUES ('" + DateTime.Now + "')";
SqlCommand myCMD = new SqlCommand(mySQL, myConn);
myConn.Open();
myCMD.ExecuteNonQuery();
myConn.Close();
myCMD.Dispose();
myConn.Dispose();

And the field 'datestamp' is a SQL Server Data Type datetime

Anyone else?
You can use getDate() method of SQL server to update date.

INSERT INTO tblname (datestamp) VALUES (getDate())";
Thanks for that - definately half way to solving my problem.
What if I need to take a value from an ASP:Calendar control?
Is there a ToDate() function that will convert it as required?
You can use

Calendar1.SelectedDate.ToShortDateString())

which will convert this date into short date format.