Welcome to Dream.In.Code
Become an Expert!

Join 150,052 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,709 people online right now. Registration is fast and FREE... Join Now!




I have an ASP.NET project and I need a little help

 
Reply to this topicStart new topic

I have an ASP.NET project and I need a little help

Daggio
6 Jun, 2008 - 09:44 PM
Post #1

New D.I.C Head
*

Joined: 6 Jun, 2008
Posts: 4


My Contributions
Hi, I'm new here and I have a little question about ASP.NET but before that maybe I can explain what my project is.
It is a graduation thesis project about an e-commerce website using ASP.NET and SQL server 200 database. At first I coded my project in ASP (before migrating to ASP.NET) I used to code the ASP in notepad++ and then run it on a web server. Now I used visual web developer express to write the ASP.NET code

Before, to access the access database (I used access before intending to use SQL server 200) I used this code

CODE

        dim adoCon
        dim pass
        dim strSQL
        dim nama_user
        dim kode_user
        dim logged_in

        Set adoCon = Server.CreateObject("ADODB.Connection")
        adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/Daggio/db/db1.mdb")
        Set pass = Server.CreateObject("ADODB.Recordset")
        pass.open "SELECT tblMemberInfo.MemberName, tblMemberInfo.Password FROM tblMemberInfo where MemberName = '"& nama_user &"'",adocon,1


so how do I do the same to connect to SQL server database using ASP.NET?
also, somehow the validation using javascript doesn't work (it worked when I used ASP) here's the javascript

CODE

            function validate_required(field,alerttxt)
            {
                with (field)
                {
                    if (value==null||value=="")
                      {alert(alerttxt);return false;}
                    else {return true}
                }
            }

            function validate_security(field,alerttxt)
            {
                with (field)
                {
                    if (value.match("<") && value.match(">") || value.match("'") || value.match("="))
                        {alert(alerttxt);return false;}
                        else {return true}
                }
            }

            function validate_form(thisform)
            {
                with (thisform)
                {
                    if (validate_required(username,"Username harus diisi!")==false)
                          {username.focus();return false;}
                    if (validate_required(password,"Password harus diisi!")==false)
                        {password.focus();return false;}
                    if (validate_security(username,"Dilarang menggunakan karakter non alphanumeric.")==false)
                        {username.focus();return false;}
                    if (validate_security(password,"DIlarang menggunakan karakter non alphanumeric.")==false)
                        {password.focus();return false;}
                }
            }


and here's how I implement it

CODE

        <form action = "Login.aspx" method = "post" onsubmit = "return validate_form(this)">
                <center>
                    <table border = "0" bgcolor = "cyan">
                        <tr>
                            <td colspan = "2" align = "center">Log in</td>
                        </tr>
                        <tr>
                            <td>Username:</td>
                            <td><input type = "text" name = "user" id = "username" onfocus = "setStyle(this.id)" onblur = "loseStyle(this.id)" /></td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td><input type = "password" name = "pass" id = "password" onfocus = "setStyle(this.id)" onblur = "loseStyle(this.id)" /></td>
                        </tr>
                        <tr>
                            <td colspan = "2"><input type = "hidden" name = "loggedin" value = "yes" /></td>
                        </tr>
                        <tr>
                            <td><input type = "submit" name = "submit" value = "Log in" /></td>
                            <td><a href = "register.asp">Belum daftar?daftar disini.</a></td>
                        </tr>
                    </table>
                </center>
        </form>


and I heard you can write ASP.NET code in notepad and then compile it in command prompt, is it true? if so how do I do it?

thanks, any help would be appreciated biggrin.gif
User is offlineProfile CardPM
+Quote Post

thor78
RE: I Have An ASP.NET Project And I Need A Little Help
8 Jun, 2008 - 06:21 PM
Post #2

D.I.C Head
Group Icon

Joined: 6 May, 2008
Posts: 107


Dream Kudos: 50
My Contributions
You can use the Data->Add Data Source menu in Visual Web Developer to add your SQL Database via a wizard.

As for your validation needs, ASP.NET has some cool validation controls included in the toolbox (Required field, regular expression, etc.). Check it out. smile.gif
User is offlineProfile CardPM
+Quote Post

mistertwisted
RE: I Have An ASP.NET Project And I Need A Little Help
13 Jun, 2008 - 12:24 PM
Post #3

New D.I.C Head
*

Joined: 27 Jan, 2005
Posts: 6


My Contributions
Hey Daggio,
You can refer to http://connectionstrings.com for help on constructing an SQL connection string. It is a bit similar to what you did. Also do check into vb.net's validation controls, they make validation tons easier! Try to use server validation too, as people can turn off their Javascript to get through vb.net's and the one you posted.

This post has been edited by mistertwisted: 13 Jun, 2008 - 12:25 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:18PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month