I am creating an application in V W D I am new to this so please bear with me I have a form that user is to fill out and if it completes it is suppose to update the sql database and then send user to another page and tell them there Ticket Number. I thought I had it working and was using a sql command to tell the ticket number by doing a select Top 1 in descending order to get the last record entered and it worked or so I thought I then looked and found my database was stuck on 10 entries and will not accept any additional records but the application does not throw any errors. Any ideas would be greatly appreciated.
%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<link href="http://links.10026.com/?link=css/CAD.css" rel="stylesheet" type="text/css" />
<title>Log the Call</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="Email" runat="server" Style="z-index: 101; left: 285px; position: absolute;
top: 273px"></asp:TextBox>
<br />
<asp:Label ID="Label1" runat="server" Style="z-index: 103; left: 78px; position: absolute;
top: 169px" Text="First Name" Width="120px"></asp:Label>
<asp:TextBox ID="PhoneX" runat="server" Style="z-index: 104; left: 665px; position: absolute;
top: 266px"></asp:TextBox>
<asp:TextBox ID="RoomN" runat="server" Style="z-index: 105; left: 508px; position: absolute;
top: 188px"></asp:TextBox>
<asp:TextBox ID="LName" runat="server" Style="z-index: 106; left: 288px; position: absolute;
top: 185px"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Style="z-index: 107; left: 293px; position: absolute;
top: 164px" Text="Last Name" Width="107px"></asp:Label>
<asp:Label ID="Label3" runat="server" Style="z-index: 108; left: 667px; position: absolute;
top: 245px" Text="Phone Extension" Width="117px"></asp:Label>
<asp:Label ID="Label4" runat="server" Style="z-index: 109; left: 286px; position: absolute;
top: 253px" Text="Email Address" Width="114px"></asp:Label>
<asp:Label ID="Label5" runat="server" Style="z-index: 110; left: 510px; position: absolute;
top: 171px" Text="Room Number" Width="104px"></asp:Label>
<asp:Label ID="Label6" runat="server" Style="z-index: 111; left: 78px; position: absolute;
top: 239px" Text="Location" Width="111px"></asp:Label>
<asp:Label ID="Label7" runat="server" Style="z-index: 112; left: 511px; position: absolute;
top: 248px" Text="Problem Type" Width="99px"></asp:Label>
<asp:Label ID="Label8" runat="server" Style="z-index: 113; left: 74px; position: absolute;
top: 329px" Text="Additional Information" Width="119px"></asp:Label>
<asp:TextBox ID="Fname" runat="server" Style="z-index: 114; left: 76px; position: absolute;
top: 187px"></asp:TextBox>
<asp:TextBox ID="AddInfo" runat="server" Height="103px" Style="z-index: 115; left: 69px;
position: absolute; top: 369px" Width="636px"></asp:TextBox>
<asp:Button ID="submit_Button" runat="server" Style="z-index: 116; left: 74px; position: absolute;
top: 500px" Text="Submit Ticket" PostBackUrl="~/LogCallConfirmed.aspx" />
<asp:DropDownList ID="Location" runat="server" Style="z-index: 117; left: 77px; position: absolute;
top: 257px">
<asp:ListItem>Administration</asp:ListItem>
<asp:ListItem>Annex</asp:ListItem>
<asp:ListItem>Billing</asp:ListItem>
<asp:ListItem>Clinic</asp:ListItem>
<asp:ListItem>Contact Lense</asp:ListItem>
<asp:ListItem>Dispensary</asp:ListItem>
<asp:ListItem>SpecialityCare</asp:ListItem>
<asp:ListItem>Spec Lab</asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem Selected="True">N/A</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="FNameRequired" runat="server" ControlToValidate="Fname"
ErrorMessage="First Name Required" Style="z-index: 118; left: 242px; position: absolute;
top: 191px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="LNameRequired" runat="server" ControlToValidate="LName"
ErrorMessage="Last Name Required" Style="z-index: 119; left: 445px; position: absolute;
top: 188px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RoomRequired" runat="server" ControlToValidate="RoomN"
ErrorMessage="Room Number Required" Style="z-index: 120; left: 665px; position: absolute;
top: 191px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="PhoneXRequired" runat="server" ControlToValidate="PhoneX"
ErrorMessage="Phone Extension Required" Style="z-index: 121; left: 834px; position: absolute;
top: 268px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ProblemType"
ErrorMessage="Problem Type Can not be N/A" Style="z-index: 122; left: 622px;
position: absolute; top: 272px">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="LocationRequired" runat="server" ControlToValidate="Location"
ErrorMessage="Location can not be N/A" Style="z-index: 123; left: 199px; position: absolute;
top: 259px">*</asp:RequiredFieldValidator>
<asp:DropDownList ID="ProblemType" runat="server" Style="z-index: 124; left: 512px;
position: absolute; top: 266px">
<asp:ListItem>Hardware</asp:ListItem>
<asp:ListItem>Software</asp:ListItem>
<asp:ListItem>Network</asp:ListItem>
<asp:ListItem>Unknown</asp:ListItem>
<asp:ListItem Selected="True">N/A</asp:ListItem>
</asp:DropDownList>
<asp:RegularExpressionValidator ID="EmailValidator1" runat="server" ControlToValidate="Email"
ErrorMessage="Please enter valid E-mail address" Style="z-index: 125; left: 442px;
position: absolute; top: 276px" ValidationExpression="\w+([-+.']\w+)*@.\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
<asp:ValidationSummary ID="CallLogValidationSummary" runat="server" Style="z-index: 126;
left: 301px; position: absolute; top: 491px" />
<asp:Literal ID="TicketN" runat="server"></asp:Literal>
<asp:Literal ID="TimeDateStamp" runat="server"></asp:Literal></div>
</form>
</body>
</html>
chalakki:
by doing a select Top 1 in descending order to get the last record entered and it worked or so I thought
This is not a desirable methodology. What happens when multiple users are working in your application? You cannot really guarantee that the highest ticket number is the same record that was just inserted, as another insert might sneak in there before the highest ticket number is retrieved.
chalakki:
I then looked and found my database was stuck on 10 entries and will not accept any additional records but the application does not throw any errors. Any ideas would be greatly appreciated.
You've not shown us any of your data access code, so we really don't have anything to go on to help you. Have you done any debugging?
Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub submit_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit_Button.Click
Dim PTicket As New SqlDataSource
PTicket.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString()
PTicket.InsertCommandType = SqlDataSourceCommandType.Text
PTicket.InsertCommand = "INSERT INTO PTicket (LName, Fname, RoomN, Location, Email, ProblemType, PhoneX, AddInfo, TimeDateStamp)VALUES(@.LName, @.Fname, @.RoomN, @.Location, @.Email, @.ProblemType, @.PhoneX, @.AddInfo, @.TimeDateStamp)"
PTicket.InsertParameters.Add("LName", LName.Text)
PTicket.InsertParameters.Add("FName", Fname.Text)
PTicket.InsertParameters.Add("RoomN", RoomN.Text)
PTicket.InsertParameters.Add("Location", Location.Text)
PTicket.InsertParameters.Add("Email", Email.Text)
PTicket.InsertParameters.Add("ProblemType", ProblemType.Text)
PTicket.InsertParameters.Add("PhoneX", PhoneX.Text)
PTicket.InsertParameters.Add("AddInfo", AddInfo.Text)
'PTicket.InsertParameters.Add("TicketN", TicketN.Text)
PTicket.InsertParameters.Add("TimeDateStamp", DateTime.Now())
'PTicket.InsertParameters.Add("LName", LName.Text)
Dim rowsAffected As Integer = 0
Try
rowsAffected = PTicket.Insert()
Catch ex As Exception
'TO Do: Probably would want to write to windows error logs
Server.Transfer("LogCallProblem.aspx")
Finally
PTicket = Nothing
End Try
If rowsAffected <> 1 Then
Server.Transfer("LogCallProblem.aspx")
Else
Server.Transfer("LogCallConfirmed.aspx")
End If
End Sub
End Class
LogCallConfirm.aspx
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>"
SelectCommand="SELECT TOP (1) TicketN FROM PTicket ORDER BY TicketN DESC"></asp:SqlDataSource>
</div>
</form>
Sorry this all new to me! I have never tried using a forum to resolve problems Any assitance would be greatly appreciated
|||I am a little confused. You said it had all seemed to be working. Does this mean that you are seeing the TicketN value incrementing?|||
OK the issue is the page forwards the user to a confirm page when the user imputs the data and hits submit, Then if no exceptions the user is sent to the Confirm Page. There the page is suppose to look up the TicketN Number and displays it to the page so user has a reference to look up, but number 11 is all it displays. The fist time I thought it and enter another page it also displayed 11 so I went to the admin page to view the table there is no additional rows have been added.
I am really confused about it as I get no erros on debug. Also if there is another alternative to giving the user there TicketN number on the confirmation page I am all for it.
Thanks
|||Sorry to answer your question it is not incrementing and no new data is being added to the table
|||OK, what's happening is that your button's click event is not even running, due to the presence ofPostBackUrl="~/LogCallConfirmed.aspx". This is posting your form to the LogCallConfirmed.aspx page, which is not what you want. Remove this attribute and value altogether and the form will now post back to itself, calling your click event as you desire.|||
Apparently I am missing something. I tried the information you posted and I still can not add to the database. I have even tried creating a new form with not reference to the LogcallConfirmed or Problem page and I still can't place information into the database. I will continue to see what I can do if you have any ideas on where else I could be going wrong I would appreciate any advice you can offer. Thanks in advance
|||Are you seeing any error messages at this point? Maybe you can post your new (presumably simpler) form if you are still having problems with it. If you still have error handling code in it, be sure that you are not just "swallowing" the error but are actually giving some sort of indication that an error occurred.
No comments:
Post a Comment