Web form for data entry

  • Hi all, would appreciate some advice on this. I've got a really basic little DB (4 or 5 tables max), and I'd like to set up a simple web form that I can host on my server where users can enter data. What would be the best way to go about this? I use SQL Server 2005 and Visual Studio 2005 to produce SRS reports, but haven't used VS for anything else yet - could this be used, and if so, could someone point me towards a "how to" guide? Or is there anything else out there which is easy to use?

    Cheers in advance!

  • This site might be of use to you.

    http://msdn2.microsoft.com/en-us/express/aa718391.aspx

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • It's going quite well thus far, I'm able to enter data into the DB, and I've got my date field being auto-filled by an insert trigger, and it's all working fine. Next step I'd like to accomplish is to have the form, instead of allowing the users to type their name in, maybe grab the login name they use on their machine and have a trigger write that to the "CreatedBy" column. Is this even possible, or am I looking at having to create a Users table in the DB?

    Edit: never mind, got it!

  • One (hopefully) final question: everything was working perfectly when I was testing it locally, it was grabbing the user name from my computer and using it where I wanted it to. However, when I deployed the web app to my test server, instead of using my user name, it was putting ASPNET in the user name field. After doing some reading around, I realised I didn't have impersonation enabled. I turned that on in the web.config file, and now it's returning a slightly different name (SQL_ADVANCED\IUSR_SQL_ADVANCED) - "SQL_ADVANCED" is the name of the box both the SQL db and the web app are running on. Is there anything I can do to have the web app get the user name of the person who is entering data via the web form from a remote machine?

  • As to auto-inserting their user name - look up "security principal" in .NET. Should get you want you want. don't bother the DB for that (do it right in the application).

    The one you want is the WINDOWS principal, not the one running the web app (which would be the "generic" Iusr, or ASPNET user). there are several ways to "skin the security principal" - look for the one dealing with "windows".

    Otherwise you'd be looking at turning on user impersonation on your web app which will open up other issues.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Scott B (2/26/2008)


    ...I'm able to enter data into the DB, and I've got my date field being auto-filled by an insert trigger

    Scott,

    This isn't what you were asking about, but I noticed your comment (above). If you only need today's date (date and time that record is inserted, which is usually the case), you can set a default value on the date column so that when a row is inserted, the date will automatically be inserted to todays date and time.

    Enter 'getdate()' in the default field for the date column in the table. If you send in no date from the webpage, you will automatically get today's date. If you are passing in a date from the webpage, it will override the default and enter the date you passed in.

    Hope this helps!

    If it was easy, everybody would be doing it!;)

  • Thanks for that. Don't suppose you can help with the other problem, I'm still having no joy at all in getting that part going? 🙂

  • Try....

    System.Security.Principal.WindowsIdentity.GetCurrent.Name.ToString()

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • I eventually got there in a roundabout way. A little more Googling led me to try something which hadn't occurred to me - disabling anonymous access within Directory Security on IIS. Everything is working fine now, thanks everyone! 😀

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply