PeOfEo
02-22-2003, 01:48 AM
How whould I go about making an error page for asp.net? You know like a 404 error page those cool ones except one for asp.net when I get an error in one of my applications?
|
Click to See Complete Forum and Search --> : asp.net error page PeOfEo 02-22-2003, 01:48 AM How whould I go about making an error page for asp.net? You know like a 404 error page those cool ones except one for asp.net when I get an error in one of my applications? Ribeyed 02-22-2003, 05:52 AM hi, within your Web.Config file you need to add this code: <configuration> <system.web> <customErrors mode="On" defaultRedirect="AppError.aspx"> <error statusCode="404" redirect="NotFound.aspx" /> <error statusCode="500" redirect="AppError.aspx" /> </system.web> </configuration> Hope this helps. PeOfEo 02-22-2003, 08:45 PM Thanks! What are my "server error in '/' applications"'s 500? Hey do you have aim or msn messanger? PeOfEo 02-23-2003, 06:49 PM web.config file, what the heck is that? Ribeyed 02-23-2003, 08:10 PM hi, a 500 is usually a error during compiling, just means there is an error in your code. The web.config if is new to ASP.NET. It allows you to make server configuration without needing the host to do anything. It normal sits in root with your global.asax file which is the ASP.NET eqivilant to the ASP global.asa file. The web.config file is written in XML and can look like this: <configuration> <system.web> <compilation defaultLanguage="vb" debug="true" /> <customErrors mode="RemoteOnly" /> <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" /> <sessionState mode="InProc" cookieless="false" timeout="20" /> <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> </system.web> <appSettings> <add key="appName" value="DBWeb" /> <add key="appAuthor" value="David Bell BA" /> </appSettings> </configuration> PeOfEo 02-24-2003, 11:22 AM AHHH NOT A GLOBAL.ASAX , my host is a nazi and wont let me use one. Is there an alternative to a an asax? Any other place I can pu the thing? Is my view state a 500 error? Also whats wrong with that code that is making it do that error? Ribeyed 02-24-2003, 01:18 PM hi, i can't think of any reason why your host would not let you use a global.asa file. Anyway you add custom errors to the web.config file and not global.asax file. Is my view state a 500 error? Yes, your error is caused by incorrect syntax in your web and validation controls. You have the following code in your page: <asp:RequiredFieldValidator id="rfvMemberName" ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat=server> Member Name is Required! </asp:RequiredFieldValidator> This is incorrect syntax in your control. The correct syntax is this: <asp:RequiredFieldValidator ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" id="rfvMemberName" runat="server" ErrorMessage="Member Name is Required!" > </asp:RequiredFieldValidator> Once you fix these errors you'll need to work on correct syntax for creating SQL querries using parameters. PeOfEo 02-24-2003, 02:12 PM Well my host wont let me put any objects into anything application level or something like that. It is a free account and all and they stomp on us people that dont like to pay for practice sites. They are real strict about loops too. The runat="server" alone did not work. I will try putting that "that feild if required" in an error message like you have it. The sql, what is wrong with that, that you have seen so far? The forum I might just ditch because it has some other problems that will be hard to fix but I am having view state errors on another project I am working on. I might try a forum again later but I whould use a different design. I like my drop down label though because it stream lines things but it limits the forums functionality. Thanks for your help so far Ill try to fix the errors on my other pages. <%@ Page Language=VB Debug=true %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OLEDB" %> <script runat="server"> Sub SubmitBtn_Click(Sender As Object, E As EventArgs) if txtrank.selecteditem.value = "Peasent" then lblrnkval.text="1" end if if txtrank.selecteditem.value = "Soldier" then lblrnkval.text="2" end if if txtrank.selecteditem.value = "Page" then lblrnkval.text="3" end if if txtrank.selecteditem.value = "Guard" then lblrnkval.text="4" end if if txtrank.selecteditem.value = "Knight" then lblrnkval.text="5" end if if txtrank.selecteditem.value = "Elite" then lblrnkval.text="6" end if if txtrank.selecteditem.value = "Lord" then lblrnkval.text="7" end if if txtrank.selecteditem.value = "Preist" then lblrnkval.text="8" end if if txtrank.selecteditem.value = "Paladin" then lblrnkval.text="9" end if if txtrank.selecteditem.value = "Apprentice" then lblrnkval.text="10" end if if txtrank.selecteditem.value = "Noble" then lblrnkval.text="11" end if Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSLogin as New DataSet Dim DBInsert As New OleDbCommand DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _ & "DATA SOURCE=" _ & Server.MapPath("/knightsempire/db/members/" _ & "members.mdb;")) DBCommand = New OleDbDataAdapter _ ("Select Count(MemberID) as TheCount " _ & "from Members Where " _ & "MemName = '" & txtMemberName.Text _ & "'", DBConn) DBCommand.Fill(DSLogin, _ "TheCount") If DSLogin.Tables("TheCount").Rows(0).Item("TheCount") = 0 Then DBInsert.CommandText = "Insert Into Members " _ & "(MemName, [Password],bots, rank, rankval, sc, d2, wc3, Email) " _ & "values (" _ & "'" & Replace(txtMemberName.text, "'", "''") & "', " _ & "'" & Replace(txtPassword.text, "'", "''") & "', " _ & "'" & Replace(txtbots.text, "'", "''") & "', " _ & "'" & Replace(txtrank.selecteditem.value, "'", "''") & "', " _ & "'" & Replace(lblrnkval.text, "'", "''") & "', " _ & "'" & Replace(ddlsc.selecteditem.value, "'", "''") & "', " _ & "'" & Replace(ddld2.selecteditem.value, "'", "''") & "', " _ & "'" & Replace(ddlwc3.selecteditem.value, "'", "''") & "', " _ & "'" & Replace(txtEmailAddress.text, "'", "''") & "')" DBInsert.Connection = DBConn DBInsert.Connection.Open DBInsert.ExecuteNonQuery() DBCommand = New OleDbDataAdapter _ ("Select MemberID from Members Where " _ & "MemberName = '" & txtMemberName.Text _ & "' and Password = '" & txtPassword.Text _ & "'", DBConn) Response.Redirect("./list.aspx") Else lblMessage.Text = "The member name you entered is in " _ & "use by another member. Please enter " _ & "another member name." End If End Sub </SCRIPT> <HTML> <HEAD> <TITLE>Register</TITLE> </HEAD> <BODY BACKGROUND="http://www12.brinkster.com/knightsempire/tilehdark.jpg" TEXT="4682b4" LINK="00ffff" VLINK="00ffff" ALINK="00ffff" LEFTMARGIN="40"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> <style> body { scrollbar-arrow-color:#003366; scrollbar-track-color:#000000; scrollbar-shadow-color:#003366; scrollbar-face-color:#000000; scrollbar-highlight-color:#003366; scrollbar-darkshadow-color:#000000; scrollbar-3dlight-color:#000000; } </style> <table bgcolor="000000" align="center" cellpadding="10" style="border: 1px solid #003366"> <tr> <td> <form runat="server"> <CENTER> <asp:Label id="lblTitle" BorderWidth="0px" BorderStyle=7 Width="90%" Font-Size="15pt" Font-Name="Ms Sans Serif" Text="New Recruits" runat="server" /> </CENTER> <P></P> <asp:Label id="lblMessage" Font-Size="12pt" Font-Name="Tahoma" runat="server" Text="Complete each field to add your account to the data base." /> <P></P><Font Face="Tahoma">Member Name:</Font><BR> <style type="text/css"> </style> <asp:TextBox id="txtMemberName" Columns="25" MaxLength="30" runat="server" /> <P></P><Font Face="Tahoma">Password:</Font><BR> <asp:TextBox id="txtPassword" Columns="25" MaxLength="30" runat="server" TextMode="Password" /> <asp:RequiredFieldValidator id="rfvPassword" ControlToValidate="txtPassword" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server"> Password is Required! </asp:RequiredFieldValidator> <P></P><Font Face="Tahoma">Repeat Password:</Font><BR> <asp:TextBox id="txtPassword2" Columns="25" MaxLength="30" runat=server TextMode="Password" /> <asp:RequiredFieldValidator id="rfvPassword2" ControlToValidate="txtPassword2" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server"> Password is Required! </asp:RequiredFieldValidator> <asp:CompareValidator id="cvPassword" ControlToValidate="txtPassword" ControlToCompare="txtPassword2" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat=server> Password fields don't match </asp:CompareValidator> <P></P><Font Face="Tahoma">Your Rank:</Font><BR> <asp:dropdownlist id="txtrank" runat="server"> <asp:ListItem value="Peasent">Peasent</asp:listitem> <asp:ListItem value="Soldier">Soldier</asp:listitem> <asp:ListItem value="Page">Page</asp:listitem> <asp:ListItem value="Guard">Guard</asp:listitem> <asp:ListItem value="Knight">Knight</asp:listitem> <asp:ListItem value="Elite">Elite</asp:listitem> <asp:ListItem value="Lord">Lord</asp:listitem> <asp:ListItem value="Preist">Preist</asp:listitem> <asp:ListItem value="Paladin">Paladin</asp:listitem> <asp:ListItem value="Apprentice">Apprentice</asp:listitem> <asp:ListItem value="Noble">Noble</asp:listitem> </asp:dropdownlist> <asp:Label id="lblrnkval" Font-Size="12pt" Font-Name="Tahoma" runat="server" Text="1" visible="false" /> <asp:RequiredFieldValidator id="rfvMemberName" ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server"> Member Name is Required! </asp:RequiredFieldValidator> <P></P><Font Face="Tahoma">Do you load bots, if so how many:</Font><BR> <asp:TextBox id="txtbots" Columns="25" MaxLength="30" runat="server" text="0" /> <P></P><Font Face="Tahoma">Email Address:</Font><BR> <asp:TextBox id="txtEmailAddress" Columns="25" MaxLength="30" runat="server" /> <asp:RequiredFieldValidator id="rfvEmailAddress" ControlToValidate="txtEmailAddress" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server"> Email Address is Required! </asp:RequiredFieldValidator> <BR><BR> <P></P><Font Face="Tahoma">Do you play Diablo2/Diablo2 x?:</Font><BR> <asp:dropdownlist id="ddld2" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <P></P><Font Face="Tahoma">Do you play StarCraft/Brood War?:</Font><BR> <asp:dropdownlist id="ddlsc" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <P></P><Font Face="Tahoma">Do you play Warcraft3?:</Font><BR> <asp:dropdownlist id="ddlwc3" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <br><br> <asp:button id="butOK" text=" OK " Type="Submit" OnClick="SubmitBtn_Click" runat="server" /> <br><br>If you encounter any errors in this application please use this <a href="http://www12.brinkster.com/knightsempire/submit.html">Link</a> </td> </tr> </table> </Form> </BODY> </HTML> Thats what I have so far for this new sign up sheet incase you are interested. PeOfEo 02-24-2003, 02:13 PM That should be all the code I need but I have view state errors on it :( Ribeyed 02-24-2003, 02:21 PM hi, if the above code is the new code then you haven't sorted out the ErrorMessage syntax yet: <asp:RequiredFieldValidator ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" id="rfvMemberName" runat="server" > Member Name is Required! </asp:RequiredFieldValidator> The text in bold is wrong. Its wrong for this control and for about 4 others on the page. You need to change it to this: <asp:RequiredFieldValidator ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" id="rfvMemberName" runat="server" ErrorMessage="Member Name is Required!" > </asp:RequiredFieldValidator> This is what is causing your error. You need to fix this before moving on to your next error. I would also like to point out that you have added a lot of new code since the last time i seen your code. Surely its better to fix your errors first before adding more code. You're SQL statement should like something like the following code. Dim CmdStr As String CmdStr = "Insert Into Members " _ & "(MemberName, [Password], EmailAddress) " _ & "values (@MemberName, @Password, @EmailAddress)" DBInsert = new OleDbCommand(CmdStr, DBconn) DBInsert.Parameters.Add("@MemberName", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@Password", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@EmailAddress", OleDbType.VarChar, 255) DBInsert.Parameters("@MemberName").Value = Replace(txtMemberName.text, "'", "''") DBInsert.Parameters("@Password").Value = Replace(txtPassword.text, "'", "''") DBInsert.Parameters("@EmailAddress").Value = Replace(txtEmailAddress.text, "'", "''") DBConn.Open() DBInsert.ExecuteNonQuery() Fix some of these errors then we can take it from there. PeOfEo 02-24-2003, 04:49 PM Thanks! Dim CmdStr As String CmdStr = "Insert Into Members " _ & "(MemName, [Password],bots, rank, rankval, sc, d2, wc3, Email) " _ & "values (@memname, @password, @bots, @rank, @rankval, @sc, @d2, @wc3, @email)" DBInsert = new OleDbCommand(CmdStr, DBconn) DBInsert.Parameters.Add("@memname", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@password", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@bots", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@rank", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@rankval", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@sc", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@d2", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@wc3", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@email", OleDbType.VarChar, 255) DBInsert.Parameters("@memname").Value = Replace(txtMemberName.text, "'", "''") DBInsert.Parameters("@password").Value = Replace(txtPassword.text, "'", "''") DBInsert.Parameters("@bots").Value = Replace(txtbots.text, "'", "''") DBInsert.Parameters("@rank").Value = Replace(txtrank.selecteditem.value, "'", "''") DBInsert.Parameters("@rankval").Value = Replace(lblrnkval.text, "'", "''") DBInsert.Parameters("@sc").Value = Replace(ddlsc.selecteditem.value, "'", "''") DBInsert.Parameters("@d2").Value = Replace(ddld2.selecteditem.value, "'", "''") DBInsert.Parameters("@wc3").Value = Replace(ddlwc3.selecteditem.value, "'", "''") DBInsert.Parameters("@email").Value = Replace(txtEmailAddress.text, "'", "''") DBConn.Open() DBInsert.ExecuteNonQuery() This is my new sql statement. Like I said this is not for the forum it is for another page but the code is the similar. It seems to be working for me now. I ran 5 tests. It seemed to be working last time though and others got errors, so only time will tell. If I redid the error messages and the sql do you think I will be meeting my evil 500 error nemesis anymore? Also on the forum you talked about more errors, I think I know which ones you are talking about. Sometimes when you log in I heard if you have a _ in your name it wont display it. That will involve a string where I have to hunt down the "_" character. It will involde some rememberoring on how to do that but it wont be too big of a deal, I have done things like it before where it hinted for the ' character and the / character, so I can actually just copy paste and edit. I never thought of using a string to insert data into my data base, I was using a dbcommand not a string, that cmdstr thing is what I am reffering to. It makes things so much easyer when you are fluent in vb6. Also I have been using vb6 data manager to make my data bases because it is a lot better then my crunny version of access. Ribeyed 02-24-2003, 05:55 PM hi, phew!!!!, good something working right. Yes if you fix the errorMessage part of your web controls and rewrite your SQL and then fix this following error im sure you will not see dreaded 500 error for a while :) The following is not correct syntax: <asp:CompareValidator id="cvPassword" ControlToValidate="txtPassword" ControlToCompare="txtPassword2" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat=server> Password fields don't match </asp:CompareValidator> This is the correct syntax <asp:CompareValidator ControlToCompare="txtPassword" ControlToValidate="txtPassword2" Display="Dynamic" ErrorMessage="Password 1 doesn't match password 2" Font-Name="Tahoma" Font-Size="10pt" id="cvPassword" Operator="Equal" runat="server" ValueToCompare="txtPassword" > </asp:CompareValidator> this is allow incorrect: <%@ Page Language=VB Debug=true %> And should be this: <%@ Page Language="VB" Debug="true" %> You should also be using the ASP.NET table tags: <asp:table runat="server"></asp:table> <asp:tablerow runat="server"></asp:tablerow> <asp:tablecell runat="server"></asp:tablecell> Hope this helps.:D PeOfEo 02-24-2003, 08:57 PM Im angry as heck because this code a lot of it was just barley modified and came almost stright out of this book I bought. There should not be this many errors. I hunted and hunted for an email or support site so I could express my angor because this is just not right when you pay $45.00 for a big tome of knowledge you expect it to work. But with these modifications this code is running smooth! Now Im off to my message board to begin the daugnting task of error hunting. PeOfEo 02-24-2003, 09:03 PM I have been using mostly html table tags. Easyer to type =) . What ware the advantages to using an asp table tag if it is going to remain static anyway? Like I am not changing the border style or the size width or visibility properties. Thanks for all your help. This has been invaluble to me. This saved me a lot a pain trying to hunt down these problems. Programming can be frustrating at times but it helps a lot to have someone who has a little more experience to help you out at times. When I get more experienced Im sure I will be able to help you help other new asp.neters work through their problems, as tme goes on more people are sure to make the shift from classic to .net PeOfEo 02-25-2003, 04:13 PM found my own error this time <form runat="server"> That was driving me nuts I could not figure out what was causing this 500 error. The I saw that I left off a asp: near the top of my code. Hopefully thats the last of them. PeOfEo 02-25-2003, 04:20 PM Nevermind. Thats a weird exception, you leave the form tag without an asp: in front of it. The debugger just about went insane and killed me with all this red code that It came up with. PeOfEo 02-25-2003, 04:30 PM Ok if I did my forum in asp.net I wanted it so that people could use html but now I have seen problems with this. All a preson has to do is leave out a </a> or a quote or something and the rest of that post and other peoples posts are messed up. How whould I go about disableing html? Ribeyed 02-25-2003, 07:15 PM hi, i think you will have to ask that in the JavaScript forum. PeOfEo 02-25-2003, 07:29 PM Yep... I am just going to have to make my own forum which means disabling html and implementing some sort of string to read a users code so they can post image.... this is going to be a ton of work. I could not find any forum source code the whould fit my hosting and or knowledge level needs. There is absolutly noting out there for asp.net besides that asp.net forum by microsoft and it requires MDSE or something like that and IT IS 70 MEG AHHHH!!!!! I am dial up, I dont have time to download that. But do I have time to write all this code. I want to do it myself so I can say I did it but, this is going to take a long long time. PeOfEo 02-27-2003, 04:18 PM Ok I think I have this page nipped in the bud but lemme post my final code. You might see something I dont so I dont kknow. I have a back up email form that is submitted when there is an error, well I have a link and the user fills it out. Its not actually automated. Anyways I recieved one form submission yesterday and I found an error, a lone runat=server that somehow I managed to not see. so that could have cause some major major major problems. Anyways here is my final cut. I am about to do the log in page after this. Then a page where users will update there stats but it will be similar to this script below. Then I am going to move on. Probably a revised version of my forum. PeOfEo 02-27-2003, 04:18 PM <%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OLEDB" %> <script runat="server"> Sub SubmitBtn_Click(Sender As Object, E As EventArgs) if txtrank.selecteditem.value = "Peasent" then lblrnkval.text="1" end if if txtrank.selecteditem.value = "Soldier" then lblrnkval.text="2" end if if txtrank.selecteditem.value = "Page" then lblrnkval.text="3" end if if txtrank.selecteditem.value = "Guard" then lblrnkval.text="4" end if if txtrank.selecteditem.value = "Knight" then lblrnkval.text="5" end if if txtrank.selecteditem.value = "Elite" then lblrnkval.text="6" end if if txtrank.selecteditem.value = "Lord" then lblrnkval.text="7" end if if txtrank.selecteditem.value = "Preist" then lblrnkval.text="8" end if if txtrank.selecteditem.value = "Paladin" then lblrnkval.text="9" end if if txtrank.selecteditem.value = "Apprentice" then lblrnkval.text="10" end if if txtrank.selecteditem.value = "Noble" then lblrnkval.text="11" end if Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSLogin as New DataSet Dim DBInsert As New OleDbCommand DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _ & "DATA SOURCE=" _ & Server.MapPath("/knightsempire/db/members/" _ & "members.mdb;")) DBCommand = New OleDbDataAdapter _ ("Select Count(MemberID) as TheCount " _ & "from Members Where " _ & "MemName = '" & txtMemberName.Text _ & "'", DBConn) DBCommand.Fill(DSLogin, _ "TheCount") If DSLogin.Tables("TheCount").Rows(0).Item("TheCount") = 0 Then Dim CmdStr As String CmdStr = "Insert Into Members " _ & "(MemName, [Password],bots, rank, rankval, sc, d2, wc3, Email) " _ & "values (@memname, @password, @bots, @rank, @rankval, @sc, @d2, @wc3, @email)" DBInsert = new OleDbCommand(CmdStr, DBconn) DBInsert.Parameters.Add("@memname", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@password", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@bots", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@rank", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@rankval", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@sc", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@d2", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@wc3", OleDbType.VarChar, 255) DBInsert.Parameters.Add("@email", OleDbType.VarChar, 255) DBInsert.Parameters("@memname").Value = Replace(txtMemberName.text, "'", "''") DBInsert.Parameters("@password").Value = Replace(txtPassword.text, "'", "''") DBInsert.Parameters("@bots").Value = Replace(txtbots.text, "'", "''") DBInsert.Parameters("@rank").Value = Replace(txtrank.selecteditem.value, "'", "''") DBInsert.Parameters("@rankval").Value = Replace(lblrnkval.text, "'", "''") DBInsert.Parameters("@sc").Value = Replace(ddlsc.selecteditem.value, "'", "''") DBInsert.Parameters("@d2").Value = Replace(ddld2.selecteditem.value, "'", "''") DBInsert.Parameters("@wc3").Value = Replace(ddlwc3.selecteditem.value, "'", "''") DBInsert.Parameters("@email").Value = Replace(txtEmailAddress.text, "'", "''") DBConn.Open() DBInsert.ExecuteNonQuery() DBCommand = New OleDbDataAdapter _ ("Select MemberID from Members Where " _ & "MemberName = '" & txtMemberName.Text _ & "' and Password = '" & txtPassword.Text _ & "'", DBConn) Response.Redirect("./list.aspx") Else lblMessage.Text = "The member name you entered is in " _ & "use by another member. Please enter " _ & "another member name." End If End Sub </SCRIPT> <HTML> <HEAD> <TITLE>Register</TITLE> </HEAD> <BODY BACKGROUND="http://www12.brinkster.com/knightsempire/tilehdark.jpg" TEXT="4682b4" LINK="00ffff" VLINK="00ffff" ALINK="00ffff" LEFTMARGIN="40"> <style> body { scrollbar-arrow-color:#003366; scrollbar-track-color:#000000; scrollbar-shadow-color:#003366; scrollbar-face-color:#000000; scrollbar-highlight-color:#003366; scrollbar-darkshadow-color:#000000; scrollbar-3dlight-color:#000000; } </style> <form runat="server"> <asp:table runat="server" bgcolor="000000" align="center" cellpadding="10" style="border: 1px solid #003366"> <asp:tablerow runat="server"> <asp:tablecell runat="server"> <CENTER> <asp:Label id="lblTitle" BorderWidth="0px" BorderStyle=7 Width="90%" Font-Size="15pt" Font-Name="Ms Sans Serif" Text="New Recruits" runat="server" /> </CENTER> <P></P> <asp:Label id="lblMessage" Font-Size="12pt" Font-Name="Tahoma" runat="server" Text="Complete each field to add your account to the data base." /> <P></P><Font Face="Tahoma">Member Name:</Font><BR> <style type="text/css"> </style> <asp:TextBox id="txtMemberName" Columns="25" MaxLength="30" runat="server" /> <asp:RequiredFieldValidator id="rfvMemberName" ControlToValidate="txtMemberName" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server" ErrorMessage="Member Name is Required!"> </asp:requiredfieldvalidator> <P></P><Font Face="Tahoma">Password:</Font><BR> <asp:TextBox id="txtPassword" Columns="25" MaxLength="30" runat="server" TextMode="Password" /> <asp:RequiredFieldValidator id="rfvPassword" ControlToValidate="txtPassword" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server" errormessage="Password is Required!"> </asp:RequiredFieldValidator> <P></P><Font Face="Tahoma">Repeat Password:</Font><BR> <asp:TextBox id="txtPassword2" Columns="25" MaxLength="30" runat= "server" TextMode="Password" /> <asp:RequiredFieldValidator id="rfvPassword2" ControlToValidate="txtPassword2" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server" errormessage="Password is required!"> </asp:RequiredFieldValidator> <asp:CompareValidator ControlToCompare="txtPassword" ControlToValidate="txtPassword2" Display="Dynamic" ErrorMessage="Password 1 doesn't match password 2" Font-Name="Tahoma" Font-Size="10pt" id="cvPassword" Operator="Equal" runat="server" ValueToCompare="txtPassword" > </asp:CompareValidator> <P></P><Font Face="Tahoma">Your Rank:</Font><BR> <asp:dropdownlist id="txtrank" runat="server"> <asp:ListItem value="Peasent">Peasent</asp:listitem> <asp:ListItem value="Soldier">Soldier</asp:listitem> <asp:ListItem value="Page">Page</asp:listitem> <asp:ListItem value="Guard">Guard</asp:listitem> <asp:ListItem value="Knight">Knight</asp:listitem> <asp:ListItem value="Elite">Elite</asp:listitem> <asp:ListItem value="Lord">Lord</asp:listitem> <asp:ListItem value="Preist">Preist</asp:listitem> <asp:ListItem value="Paladin">Paladin</asp:listitem> <asp:ListItem value="Apprentice">Apprentice</asp:listitem> <asp:ListItem value="Noble">Noble</asp:listitem> </asp:dropdownlist> <asp:Label id="lblrnkval" Font-Size="12pt" Font-Name="Tahoma" runat="server" Text="1" visible="false" /> <P></P><Font Face="Tahoma">Do you load bots, if so how many:</Font><BR> <asp:TextBox id="txtbots" Columns="25" MaxLength="30" runat="server" text="0" /> <P></P><Font Face="Tahoma">Email Address:</Font><BR> <asp:TextBox id="txtEmailAddress" Columns="25" MaxLength="30" runat="server" /> <asp:RequiredFieldValidator id="rfvEmailAddress" ControlToValidate="txtEmailAddress" Display="Dynamic" Font-Name="Tahoma" Font-Size="10pt" runat="server" ErrorMessage="Email is Required, If none put n/a!"> </asp:RequiredFieldValidator> <BR><BR> <P></P><Font Face="Tahoma">Do you play Diablo2/Diablo2 x?:</Font><BR> <asp:dropdownlist id="ddld2" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <P></P><Font Face="Tahoma">Do you play StarCraft/Brood War?:</Font><BR> <asp:dropdownlist id="ddlsc" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <P></P><Font Face="Tahoma">Do you play Warcraft3?:</Font><BR> <asp:dropdownlist id="ddlwc3" runat="server"> <asp:ListItem value="-">No</asp:listitem> <asp:ListItem value="<li>">Yes</asp:listitem> </asp:dropdownlist> <br><br> <asp:button id="butOK" text=" OK " Type="Submit" OnClick="SubmitBtn_Click" runat="server" /> <br><br>If you encounter any errors in this application please use this <a href="http://www12.brinkster.com/knightsempire/submit.html">Link</a> </asp:tablecell> </asp:tablerow> </asp:table> </form> </BODY> </HTML> Ribeyed 02-27-2003, 06:18 PM hi, here thats great well done, your code looks ok to me, are you getting any errors at all from the page, if not then it is fine. Again well done;) PeOfEo 02-27-2003, 08:11 PM I am still getting a few quirky errors here and there odly enough. The numbers have droped dramatically but the code is not perfect... Look at this in particualr tell me what you think ("Select Count(MemberID) as TheCount " _ & "from Members Where " _ & "MemName = '" & txtMemberName.Text _ & "'", DBConn) DBCommand.Fill(DSLogin, _ "TheCount") If DSLogin.Tables("TheCount").Rows(0).Item("TheCount") = 0 Then Dim CmdStr As String CmdStr = "Insert Into Members " and then DBCommand = New OleDbDataAdapter _ ("Select MemberID from Members Where " _ & "MemberName = '" & txtMemberName.Text _ & "' and Password = '" & txtPassword.Text _ & "'", DBConn) My data base name is members.mdb the table this is in is members and that particualr feild with the members name is memname I think that that member I have hilighted should be changed to memname. What do you think? I whould go ahead and change it right now but my host is doing some server stuff right now and I whould rather not edit anything actually online today Ribeyed 02-28-2003, 06:21 AM hi, im my databases i usually perfix all the table names with tbl, for example: tblMembers tblForum tblPosts etc..... What do you think? I whould go ahead and change it? Well yes becuase your field is called menname and not membername like you have in the bottom code. Also i would change the select statement and the count staement to the same syntax as your Insert statement for accepting parameters. PeOfEo 02-28-2003, 11:52 AM What whould that look like though? celebguy_dv 03-03-2003, 11:31 PM http://banners.dollarmachine.com/pic/2014000/hal001.gif (http://www.kinkyceleb.com/1261795520) celebguy_dv 03-04-2003, 12:19 AM http://banners.dollarmachine.com/pic/2014000/hal001.gif (http://www.kinkyceleb.com/1261795520) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |