Jump to content
Xtreme .Net Talk

lorena

Avatar/Signature
  • Posts

    134
  • Joined

  • Last visited

Everything posted by lorena

  1. I tried that and it doesn't seem to make a difference. I am not getting an error message, the query either doesn't run or doesn't update the database. Here is a simplified version (extra choices have been removed) of my code: Public Sub btnSubmit_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim itmSmoke As ListItem Dim strTest As String For Each itmSmoke In rblSmoke.Items If itmSmoke.Value = "NoSm" Then strCat = "NoSm" End If Next BindData(strCat, strSubCat) btnSubmit.Enabled = False lblThanks.Visible = True End Sub Sub BindData(ByVal strVal1 As String) Dim objConn As New OleDb.OleDbConnection(strConnString) Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn) Dim objDS As New DataSet() strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _ "WHERE Category = '" & strVal1 & "'" objConn.Open() objCommand.ExecuteNonQuery() objConn.Close() Label1.Text = "Record Updated" End Sub I just don't know what I am doing wrong.
  2. I have an aspx form with a radiobuttonlist that a user can select from. When the user makes a choice and clicks "Submit", all I want to do is to go to that value in the currentTotal field and increment it by 1. Here is my query: strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _ "WHERE Category = '~' " strSQL = Replace(strSQL, "~", strVal1) I am using VS.Net and it does not like my query and does not update the database. I am connecting (or trying to connect) to an Access db. The query works in access. I think I am making this harder than it needs to be. I would appreciate any help.
  3. I was going to try incrementing an integer value for each checkbox that is checked and writing it to a textbox which would be validated on submit but I can't get the textbox to automatically update. Would this be a workable solution?
  4. I could use some help with the Javascript - Thanks!
  5. I have a form with a checkboxlist that has several choices. Because the person who requested this form also wants a choice "Other" with an associated textbox to explain the choice, I added "Other" as a checkbox. I need to validate on submit, that either one item from the checkboxlist or the checkbox has been chosed. Is there an easy way to do this? Or, let me rephrase, is there any way to do this?
  6. Figured it out. All I needed to do was set "CausesValidation" on the image buttons to "False"
  7. I have a small asp.net app that loads a login page with two textboxes for username and password and a login button. Each textbox has a RequiredFieldvalidator and I use the Page.IsValid for the OnClick event of the Login button. I also have two hyperlinks on the page so that users can go back to non-login pages. My problem is that the RequiredFieldvalidator events fire when either hyperlink is clicked and keep the hyperlinks from allowing users to navigate off of the page. <script language="VB" runat="server"> 'Code for the login button Sub Login_Click(Src As Object, E As EventArgs) If Page.IsValid Then Dim strUN as string = txtUN.text Dim strPW as string = txtPwd.text Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & server.mappath("DB/sf.mdb") & ";" Dim Conn as New OLEDBConnection(strConn) Conn.Open() Dim strSQL as string = "SELECT * FROM info WHERE un = '~' and pwd= 'Val1'" strSQL = Replace(strSQL,"~", strUN) strSQL = Replace(strSQL,"Val1", strPW) Dim Cmd as New OLEDBCommand(strSQL,Conn) 'Create a datareader, connection object Dim Dr as OLEDBDataReader = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection) 'Get the first row and check the password. If Dr.Read() then If Dr("Pwd").ToString = txtPwd.text and DR("UN").ToString=txtUN.text Then FormsAuthentication.RedirectFromLoginPage(txtUN.Text, false) Else lblLoginMsg.text = "Invalid login attempt." End If Else lblLoginMsg.text = "Login name or Password not found." End If Dr.Close End If End Sub Sub tds_img_OnClick(Sender As Object, E As ImageClickEventArgs) If not Page.IsValid then FormsAuthentication.SignOut() Response.Redirect ("http://www.homepage.com") End If End Sub Sub sup_img_OnClick(Sender As Object, E As ImageClickEventArgs) FormsAuthentication.SignOut() Response.Redirect ("http://www.homepage.com/sup/welcome.htm") End Sub </script> Is there someway to get around this? Some Page event that I am missing? Thanks in advance for any help.
  8. Never mind - I figured it out by using: FormsAuthentication.SignOut() User hits the back button and it takes them back to the login page
  9. Isn't is true that if an aspx page's OutputCache location="None", it expires immediately? If the user hits the back button on the browser, the page should not be there, right? Here is my code: <%@OutputCache Location="None"%> <%@ Page Language="vb" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>Current Suppliers</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <script runat="server"> Sub btnLogout_OnClick(Sender As Object, E As EventArgs) Response.Redirect ("http://internet.talleyds.com") End Sub </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 98px; POSITION: absolute; TOP: 59px" runat="server" Width="144px">Hi!</asp:Label> <asp:Button id="btnLogout" style="Z-INDEX: 102; LEFT: 237px; POSITION: absolute; TOP: 146px" runat="server" OnClick="btnLogout_OnClick" Text="Logout"></asp:Button> </form> </body> </HTML> Have I missed something?
  10. Thanks very much!!
  11. Is there a way to disallow users selecting a date that has already passed? I have an .aspx page that is used to request an item by a certain date and I want to be sure people don't select a date prior to today. Thanks for any help.
  12. I maintain our company's intranet. I have some asp pages that I am re-writing in .NET. These pages list and link files in a number of folders. Some of these files are .pdf which is no problem but some are Word or Excel templates. With the ASP pages, after much searching MS Knowledge Base, I had to create shortcuts to each template in order to have it open properly due to the fact that we have users with different operating systems (win98, 2000 and XP). Otherwise, the link would open the template, download the file and so forth. Is there a way to open a Word or Excel template in ASP.NET without creating shortcuts to the templates? Thanks for any help or advice
  13. Thanks! I finally wound up going back and rebuilding the grid from scratch. Whatever I had that was hosed up seems to be corrected. Now I am trying to go back and make Template Columns with Edit Templates and validation. Wish me luck :) Thanks for your help
  14. I have an asp.net page with a dropdown list which enables the user to choose the kind of data they view. Once the data is displayed, the user can edit the records displayed. Everything works fine except when the record is edited, the new values don't show up in the database. I have had a label display the sql query and parameter values. It displays the current values, not the changed values. Here is my code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then 'check the selected value of the dropdown list - "arc" is archive If ddlView.SelectedItem.Value <> "arc" Then CreateQuery() BindData() End If End If End Sub Sub BindData() Dim objConn As New OleDb.OleDbConnection(strConnString) CreateQuery() Dim objCmd As New OleDb.OleDbCommand(strSQL, objConn) objConn.Open() Dim objDR As OleDb.OleDbDataReader objDR = objCmd.ExecuteReader() dgRecs.DataSource = objDR dgRecs.DataBind() objConn.Close() End Sub Sub CreateQuery() 'creates the SQL query based on the selected value of the dropdownlist Dim intMo As Integer Dim intYr As Integer 'Archive - user can select month and year to view/edit archived data If ddlView.SelectedItem.Value = "arc" Then intMo = ddlMonth.SelectedItem.Value intYr = ddlYear.SelectedItem.Value dtBeg = DateSerial(intYr, intMo, 1) dtEnd = DateSerial(intYr, intMo, 1 - 1) strSQL = "SELECT * FROM toolroom_test " & _ "WHERE PRIORITY='DONE' " & _ "AND COMPLETE_DATE BETWEEN #" & dtBeg & "# AND #" & dtEnd & "#" 'Reject - user can view/edit any records that have been rejected ElseIf ddlView.SelectedItem.Value = "rej" Then strSQL = "SELECT * FROM toolroom_test " & _ "WHERE ACCEPT='REJ'" 'View/Edit all current records ElseIf ddlView.SelectedItem.Value = "all" Then strSQL = "SELECT * FROM toolroom_test " & _ "WHERE (ACCEPT='ACC' AND (PRIORITY<>'DONE' And ACCEPT<>'REJ')) " & _ "ORDER BY PRIORITY" 'View/Edit any Pending records ElseIf ddlView.SelectedItem.Value = "pen" Then strSQL = "SELECT * FROM toolroom_test " & _ "WHERE ACCEPT='PEND' " End If End Sub 'Show or Hide the panel containing the month and year when the "View" button is clicked Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click CreateQuery() BindData() If ddlView.SelectedItem.Value <> "arc" Then pnlMoYr.Visible = False End If End Sub Private Sub ddlView_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlView.SelectedIndexChanged If ddlView.SelectedItem.Value = "arc" Then pnlMoYr.Visible = True Else pnlMoYr.Visible = False CreateQuery() BindData() End If End Sub Sub dgRecs_UpdateRow(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Const strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\toolroom.mdb" Dim strSQL As String If Not Page.IsValid Then Exit Sub Dim cptTextBox As TextBox = e.Item.Cells(11).Controls(0) Dim iRecID As Integer = dgRecs.DataKeys(e.Item.ItemIndex) strSQL = "UPDATE toolroom_test SET complete_date = @cptParam" & _ " WHERE rec_id = @idparam " Dim objConn As New OleDb.OleDbConnection(strConnString) Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn) Dim cptParam As New OleDb.OleDbParameter("@cptParam", OleDb.OleDbType.Date) Dim idparam As New OleDb.OleDbParameter("@idparam", OleDb.OleDbType.Integer) 'Complete Date If Trim(cptTextBox.Text) = "" Then cptParam.Value = Convert.DBNull Else cptParam.Value = cptTextBox.Text End If objCommand.Parameters.Add(cptParam) 'Record ID idparam.Value = iRecID objCommand.Parameters.Add(idparam) objConn.Open() objCommand.ExecuteNonQuery() Label2.Text = idparam.Value & "," & cptParam.Value & "," & strSQL objConn.Close() dgRecs.EditItemIndex = -1 BindData() End Sub I hope this makes sense. I would appreciate any help. Thanks
  15. I have a grid which should (in theory) allow the user to enter a new value for a field and write that value to the database. The record does not update when the user clicks "Update". I have the grid set so that the event is "dgRecs_UpdateRow" on the grid. I put a label on the form to show the values of the parameters being written and the parameter which should change, never does. Here is my code: Sub dgRecs_UpdateRow(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Label2.Text = "" If Not Page.IsValid Then Exit Sub irecordID = dgRecs.DataKeys(e.Item.ItemIndex) Dim Acc As TextBox = e.Item.Cells(12).Controls(0) Dim objConn As OleDb.OleDbConnection Dim objCommand As OleDb.OleDbCommand objConn = New OleDb.OleDbConnection(strConnString) objCommand = New OleDb.OleDbCommand(strSQL, objConn) strSQL = "UPDATE [toolroom] " & _ " set [ACCEPT] = @accParam, " & _ " WHERE [REC_ID] = @recordIDParam " Dim accParam As New OleDb.OleDbParameter("@accParam", OleDb.OleDbType.VarChar, 25) accParam.Value = Acc.Text objCommand.Parameters.Add(accParam) 'Record ID Dim recordIDParam As New OleDb.OleDbParameter("@recordIDParam", OleDb.OleDbType.Single) recordIDParam.Value = irecordID objCommand.Parameters.Add(recordIDParam) objConn.Open() objCommand.ExecuteNonQuery() Label2.Text = recordIDParam.Value & "," & accParam.Value objConn.Close() dgRecs.EditItemIndex = -1 ddlView.SelectedIndex = -1 BindData() End Sub I would REALLY appreciate some help with this. Thanks
  16. I hava a datagrid that I am setting up for editing. Two fields have a limited selection of values so the cells with those fields are set up as dropdowns when "Edit" is clicked. I am having a problem setting the initial value for the dropdown list. The values load into the list okay but I can't figure out how to make the initial value in the dropdown match the value of the database field. Here is the code for the datagrid row: <asp:TemplateColumn HeaderText="Type"> <ItemTemplate><asp:Label Runat="server" id="lblType" Width="60px" text='<%# DataBinder.Eval(Container.DataItem, "Type") %>'/></ItemTemplate> <EditItemTemplate> <asp:DropDownList Runat="server" ID="ddlType" Font-Name="Verdana" Font-Size="xx-small" DataTextField="Type" DataValueField="Type" DataSource="<%# GetTypes() %>"> </asp:DropDownList></EditItemTemplate></asp:TemplateColumn> This is the code for the function that fills the dropdown: Function GetTypes() As DataSet Const strSQLT As String = "Select DISTINCT Type from toolroom" Dim objConn As New OleDb.OleDbConnection(strConnString) Dim myDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(strSQLT, objConn) myDA.Fill(ddlType, "toolroom") objConn.Close() Return ddlType End Function Any suggestions would be appreciated
  17. Never mind - I found the problem - the recordIDParam was out of sequence. Thanks for the help
  18. The problem seems to be that even though the code says "Parameter.Add" - the SQL string doesn't contain the parameter values. If I output the query string at this point it is: "UPDATE toolroom SET Type = @typeParam, Dwg_No = @dwgParam WHERE RecID = @recordIDParam "
  19. Everything is fine until I click "Update" and this line: dwgParam.Value = textDwg.Text appears to be causing the problem
  20. I am working with a datagrid that the user (hopefully) will be able to edit/update The columns are template columns. The grid loads fine but when I change the cell data and click "Update" - I get "Object reference not set to an instance of an object" Here is the update code: Sub dgRecs_UpdateRow(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Const strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\toolroom_sched.mdb" Dim textDwg As TextBox = e.Item.Cells(3).FindControl("txtDwg") Dim ddlT As DropDownList = e.Item.Cells(2).FindControl("ddlType") Dim irecordID As Integer irecordID = dgRecs.DataKeys(e.Item.ItemIndex) Dim strSQL As String strSQL = "UPDATE toolroom SET Type = @typeParam, @dwgParam WHERE RecID = @recordIDParam " Dim objConn As New OleDb.OleDbConnection(strConnString) Dim objCommand = New OleDb.OleDbCommand(strSQL, objConn) objConn.Open() objCommand.CommandType = CommandType.Text Dim recordIDParam As New OleDb.OleDbParameter("@RecordIDParam", OleDb.OleDbType.Single) recordIDParam.Value = irecordID objCommand.Parameters.Add(recordIDParam) Dim typeParam As New OleDb.OleDbParameter("@typeParam", OleDb.OleDbType.VarChar, 25) typeParam.Value = ddlT.SelectedItem.Text objCommand.Parameters.Add(typeParam) Dim dwgParam As New OleDb.OleDbParameter("@dwgParam", OleDb.OleDbType.VarChar, 25) dwgParam.Value = textDwg.Text objCommand.Parameters.Add(dwgParam) objCommand.ExecuteNonQuery() objConn.Close() dgRecs.EditItemIndex = -1 BindData() End Sub And part of the datagrid code: <asp:datagrid id="dgRecs" runat="server" AutoGenerateColumns="False" DataKeyField="Rec_ID" OnEditCommand="dgRecs_EditRow" OnUpdateCommand="dgRecs_UpdateRow" OnCancelCommand="dgRecs_CancelRow"> <Columns> <asp:EditCommandColumn ButtonType="LinkButton" HeaderText="EDIT" EditText="Edit" UpdateText="Update" CancelText="Cancel"></asp:EditCommandColumn> <asp:BoundColumn DataField="Rec_ID" HeaderText="Rec ID" ReadOnly="True"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Type"> <ItemTemplate> <asp:Label Runat="server" id="lblType" Width="60px" text='<%# DataBinder.Eval(Container.DataItem, "Type") %>'/> </ItemTemplate> <EditItemTemplate> <asp: DropDownList Runat="server" ID="ddlType" Font-Name="Verdana" Font-Size="xx-small" DataTextField="Type" DataValueField="Type" DataSource="<%# GetTypes() %>"> </asp: DropDownList></EditItemTemplate></asp:TemplateColumn> <asp:TemplateColumn HeaderText="Dwg No" HeaderStyle-CssClass="tdBasic"> <ItemTemplate> <asp:Label Runat="server" id="lblDwgNo" Width="60px" Text=' <%# DataBinder.Eval(Container.DataItem, "Dwg_No") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox Runat="server" ID="txtDwgNo" Width="100px" Font-Name="Verdana" Font-Size="xx-small" Text='<%# DataBinder.Eval(Container.DataItem, "Dwg_No") %>'> </asp:TextBox></EditItemTemplate></asp:TemplateColumn> <asp:TemplateColumn HeaderText="Description"> I am just not sure what I am doing wrong. :(
  21. I have a table that populates a datagrid for a user to edit. When the user clicks "Edit", one of the columns needs to be a dropdown list so only certain choices will be entered in the database. The list only has 5 values and I want to call a function which creates an array or arraylist to populate the dropdown. I am having a problem because the dropdown control doesn't actually exist until the user clicks Edit so I am having problems referring to it by code. Here is the template code for the template column: <asp:TemplateColumn HeaderText="Type"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "Type") %> </ItemTemplate> <EditItemTemplate> <asp:DropDownList Runat="server" ID="ddlType" DataValueField="Type" DataSource="<%# GetTypes() %>"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> And this is the function code(so far): Function GetTypes() As DataSet Dim oTypes As New ArrayList() oTypes.Add("PROD") oTypes.Add("TOOL") oTypes.Add("REWORK") oTypes.Add("SHOP AID") oTypes.Add("PROTO") End Function How do I bind this array to the dropdown control? I cannot do it inline with the control because I need to set the selected value for the dropdown to the value contained in the cell (and the unedited record). I hope I am making sense. Any help would be appreciated. Thanks in advance
  22. I am using a list of files from a particular folder to populate a datagrid on an asp.net page. Since there are quite a few files in the folder, I want to do custom paging on the datagrid. I am using "GetFiles" to get the array of files. How can I get a count of the files in the folder? Thanks in advance
  23. Yes, I was confused about where the .NET needed to be installed.
  24. Thanks very much. I will check that out.
  25. We are in the process of migrating our production database (Oracle 10) to a Linux server. I understand that we cannot install the Microsoft .Net framework on the Linux server. Is it possible to access the database using ADO.Net to build VB.Net and ASP.Net apps? If so, how? I have not been able to find any information on this. Maybe I am not the Googler I thought myself to be. Any help is appreciated!
×
×
  • Create New...