
jenn5175
Avatar/Signature-
Posts
35 -
Joined
-
Last visited
jenn5175's Achievements
Newbie (1/14)
0
Reputation
-
Okay - SO confused! I have a VB.NET app that I want to run at a scheduled time. I have multiple other apps working just fine. But this one app is giving me issues. I have it scheduled and it appears to run - the "Last time run" field updates and an entry gets put into SchedLgU.txt saying it started and stopped with an exit code of (0). However, it isn't truly running. Within the app I have it write to my own log file at each step and it never even gets to the first writing. I have commented out all code except the first write to my log file (and inside a try/catch so I should get a result even if it errored). I am using the exact code (to put an entry in the log file) as in another app I wrote which is working fine with the task scheduler. I took off all references inside the project except those also in the working app. Oh - forgot to mention the app runs fine when I just manually double click the exe. Just not when either scheduled to run or manually choose "run" through the task scheduler. I am at a dead end. What would cause the task scheduler to report back that it ran the app just fine but yet the app never got to line 1 to do a simple file write? Are there any references what cannot be used with the task scheduler in VB.NET? What else can I try, since commenting the entire logic out didn't help? Jenn
-
Thank you guys for testing this for me! I think I realize what my problem is. It was my own lack of knowledge. I was assuming the validator was always called on submit. But it turns out it is called only when there is a value in the textbox. So during my testing I was just hitting submit with a blank textbox. Duh! However, this brings a new issue that maybe you guys can help me brainstorm around. What I was going to use the customvalidator for was a senerio such as this: I have a dropdown of company names. The 0 index of the listbox says "New Company". Then there is a textbox for them to type a new company name (if they don't like any of the dropdown choices). I wanted my validator to check if the index of the listbox was set to zero and the text box was blank to display an error. But looks like CustomValidator isn't the way to go because it won't fire if the new company name textbox is blank. I was looking into CompareValidators but don't think they have the flexibility I need. And can't use RequiredValidator because I only want the field required if the dropdown index is 0 on a seperate control. The way I see it my only option is to do my error checking in my submit_click sub and not use any built in validators. Right? Jenn
-
I guess what I am looking for is someone to cut and paste the code I provided and try my exact code themselves to let me know if it does or doesn't work. I don't know what is wrong - in my head it "should" work - so any suggestions are welcome. Like I said, I have cut and pasted many examples and all work fine so I just need to find out what is wrong with MY code. Thanks, Jenn
-
I am so frusterated. I am trying to learn how to use the Custom Validator control since this is my first ASP.NET project. So I have cut and pasted a ton of examples and they all work, but when I try it myself the OnServerValidate function is never even called (verified using break points)! So I took a very simple example from the web: IN WEBFORM1.ASPX : <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="MediaLibrary.WebForm1"%> <form method="post" runat="server"> Enter your favorite prime number: <asp:textbox id="txtPrimeNumber" runat="server"></asp:textbox> <asp:customvalidator id="custPrimeCheck" runat="server" ControlToValidate="txtPrimeNumber" ErrorMessage="Invalid Prime Number" OnServerValidate="PrimeNumberCheck"></asp:customvalidator><br> <asp:button id="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit"></asp:button></form> IN WEBFORM1.ASPX.VB Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) If Page.IsValid Then Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is, indeed, a good prime number.</i></font>") Else Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is <b>not</b> a prime number.</i></font>") End If End Sub Sub PrimeNumberCheck(ByVal sender As Object, ByVal args As ServerValidateEventArgs) Dim iPrime As Integer = CInt(args.Value), iLoop As Integer, _ iSqrt As Integer = CInt(Math.Sqrt(iPrime)) For iLoop = 2 To iSqrt If iPrime Mod iLoop = 0 Then args.IsValid = False Exit Sub End If Next args.IsValid = True End Sub This worked. So then I pasted my control in there also to validate so the pages became: IN WEBFORM1.ASPX <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="MediaLibrary.WebForm1"%> <form method="post" runat="server"> Enter your favorite prime number: <asp:textbox id="txtPrimeNumber" runat="server"></asp:textbox> <asp:customvalidator id="custPrimeCheck" runat="server" ControlToValidate="txtPrimeNumber" ErrorMessage="Invalid Prime Number" OnServerValidate="PrimeNumberCheck"></asp:customvalidator><br> Company name: <asp:textbox id="txtNewCompanyName" runat="server"></asp:textbox> <asp:customvalidator id="valCompanyName" runat="server" ControlToValidate="txtNewCompanyName" ErrorMessage="INVALID COMPANY NAME" OnServerValidate="validateCompanyName"></asp:customvalidator><br> <asp:button id="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit"></asp:button></form> IN WEBFORM1.ASPX.VB Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) If Page.IsValid Then Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is, indeed, a good prime number.</i></font>") Else Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is <b>not</b> a prime number.</i></font>") End If End Sub Sub PrimeNumberCheck(ByVal sender As Object, ByVal args As ServerValidateEventArgs) Dim iPrime As Integer = CInt(args.Value), iLoop As Integer, _ iSqrt As Integer = CInt(Math.Sqrt(iPrime)) For iLoop = 2 To iSqrt If iPrime Mod iLoop = 0 Then args.IsValid = False Exit Sub End If Next args.IsValid = True End Sub Sub validateCompanyName(ByVal sender As Object, ByVal args As ServerValidateEventArgs) args.IsValid = False End Sub The first example of validation still works great. But I can never get validateCompanyName to be called! Why? I am at a loss as to what to try next. I have cut and pasted the working code and just replaced variables even and still nothing. HELP! Jenn
-
That's almost exactly what I tried already. Here's my attempt and the failed result. Let me know if I implemented it incorrectly: 'cmboObject.vb - class defination file Public sub Empty() _name = "" _code = "" end sub 'frmMain.vb - main form file public sub ClearVariables() brochureMake1.Empty brochureMake2.Empty ... end sub When the survey first starts it calls ClearVariables() and everything is fine. However, once the survey is filled out once, when ClearVariables() is called again I get the following error (at the line calling Empty): A managed NullReferenceException occurred at Application::Run+0xf What am I doing wrong? I tried and it errors regardless of if anything was set in brochureMake1/2 or not.
-
Okay, this is going to be remedial for most of you. I have a combobox which needed to be associated with both a code(varchar) and the display name (varchar). So I made a new class: public class cmboObject public _name as string public _code as string public sub new(byval name as string, byval code as string) _name = name _code = code end sub public readonly property Name() as string get return _name end get end property public readonly property Code() as string get return _code end get end property public overrides function ToString() as string return name end function end class I use the same comboboxes for multiple questions (the app is a survey showing one question at a time) so I made a variable to hold their choice once they move to the next question Dim brochureMake1 as cmboObject Dim brochureMake2 as cmboObject Then when the comboboxes were filled from a database I used: Dim cmboObjHolder as cmboObject while dtr.read() cmboObjHolder = new cmboObject(dtr("field1"), dtr("field2")) cmboMake1.Items.Add(cmboObjHolder) end while Now when they got to the combobox and hit "Next Question" I would simply save that cmboObject: brochureMake1 = cmboMake1.SelectedItem This above code works great. However, once the survey is submitted, I need to clear all of the variables to get ready for the next person taking the survey. I have tried everything to reset brochureMake1 and brochureMake2 to emptiness (tries = "", = nothing, etc) but keep getting "NullCastException". I am thinking I need to make a "set" function and just set name and code to "" but I cannot get it right. Any suggestions? Jenn
-
Okay, so I attempted do follow you guys and here's what I came up with (doesn't work). Where am I not thinking correctly? (I cut out most of my variables so it would be easier to read) globals.vb Module globals Public Class objGlobal Dim iUserID As Integer Public Sub New() MyBase.New() End Sub Function getVar(ByVal sVar) Select Case sVar Case "iUserID" Return iUserID End Select End Function Sub setVar(ByVal sVar, ByVal sValue) Select Case sVar Case "iUserID" iUserID = sValue End Select End Sub End Class End Module Then in my Forms I use: Dim objGlobal As New objGlobal objGlobal.setVar("iUserID", ObjReader("iUserID")) -OR - Dim objGlobal As New objGlobal iUserID = objGlobal.getVar("iUserID") However, because I am making a new global object in each form the values I set are only good for that form. If I setVar in one form then go to getVar in another form its reset back to zero. But if I don't use "Dim objGlobal as NEW objGlobal" then I get an error saying "Object is not set to instance" or something. How can I get the setVar to set it across all forms? Jenn
-
Thanks - I knew there was a simple answer! Jenn
-
Hey - this may be a simple one, I just haven't done it so I'm not sure of the syntax. I have a tabbed application. Two of the tabs have a similar combobox - a list of all shipments for the day. The comboboxes are populated from a SQL server db. I have one function to populate one of the boxes, and now that I've added a second box I would like to reuse the function to populate that one. However inside the function I have to reference the combobox - how can I vary this depending on which combobox I want to populate/update? Here's my populating function - can someone help me revise it so it makes no hardcoded references to any one control? Public Sub Build_ShipmentCBO(ByVal iShipSelectedID) '*** Initialize Stuff iShipSelectedIndex = 0 i = 1 cboShipments.Items.Clear() ObjConn.Open() ObjSQLCmd.Connection = ObjConn '*** Get Record Count for redim-ing object sSQL = "SELECT count(*) FROM tShipments WHERE iEventID=" & eventItems(cboEvents.SelectedIndex - 1).ID ObjSQLCmd.CommandText = sSQL iRecordCount = ObjSQLCmd.ExecuteScalar() '*** Select all shipments for event and put into record set sSQL = "SELECT iShipmentID, sShipDesc FROM tShipments WHERE iEventID=" & eventItems(cboEvents.SelectedIndex - 1).ID & " ORDER BY sShipDesc" ObjSQLCmd.CommandText = sSQL ObjReader = ObjSQLCmd.ExecuteReader '*** Redim object to size it needs to be ReDim shipmentItems(iRecordCount + 1) '*** Make first entry always be "Choose" shipmentItems(0) = New Class1 shipmentItems(0).Text = "Choose Shipment" shipmentItems(0).ID = 0 cboShipments.Items.Add(shipmentItems(0)) '*** NEED TO CHANGE THIS LINE While ObjReader.Read() '*** Instantiate our item object and fill it with useful information. shipmentItems(i) = New Class1 shipmentItems(i).Text = ObjReader("sShipDesc").ToString shipmentItems(i).ID = ObjReader("iShipmentID") If ObjReader("iShipmentID") = iShipSelectedID Then iShipSelectedIndex = i End If cboShipments.Items.Add(shipmentItems(i)) '*** NEED TO CHANGE THIS i = i + 1 End While ObjReader.Close() ObjConn.Close() cboShipments.SelectedIndex = iShipSelectedIndex '*** NEED TO CHANGE THIS End Sub Thanks Jenn
-
How to talk between forms not directly related?
jenn5175 replied to jenn5175's topic in Windows Forms
PlausiblyDamp, How can I pass a reference for a function? Can you point me to a tutorial? I know how to pass variables but not how to pass a function reference. Thanks! Jenn -
Okay, I have 3 Windows forms - FormA, FormB, FormC. FormA is the main form which has a datagrid of all shipping containers for a certain shipment pulled from a SQL db. I use a function dgFill() on FormA to fill this when a shipment is chosen from a combobox on FormA. If the user wants to add a container, I have a cmd button on FormA which opens FormB - containing a textbox to fill in the barcode of the new container (this will eventually get changed to a barcode scanning module) and a cmd button to add container. Once the cmd button is clicked FormB hides, the new container is added, and FormC opens which allows them to add items to the new container. Once they are done adding items, I want to have a button which not only closes FormC, but refreshes the datagrid in FormA. If FormA had opened FormC I know how to reference dgFill() and call it from FormC before hiding FormC. But because FormB is the parent of FormC, I am at a loss. Simply put: FormA -> opens FormB FormB -> opens FormC FormC -> refeshes FormA I was thinking either (a) if I could call dgFill() from FormC before hiding it or (b) have some sort of "OnFocus" function on FormA so it refreshes everytime FormA is brought into focus. Any thoughts? Jenn
-
I'm not sure either of these are exactly what I need. Here's a different senerio - let me know if I'm just not thinking about this correctly. I have a login form first. This will run to the daatabase, verify the user, and return what this user has permission to do. Throughout the entire rest of the program (multiple forms) I need that user id and permissions readily available - not having to instanciate a new class or call a function or anything. Just grab the ID so I can stick it into the database when they add a record. I am more familiar with doing web apps so I would just use a session variable for the ID and one for the permission level. How does that equate to a desktop app? If its still by using the above examples I guess I didn't quite understand - can you elaborate or point me to a related tutorial? Thanks so much!!! Jenn
-
Simple SQL statement I can't seem to get right
jenn5175 replied to jenn5175's topic in Database / XML / Reporting
Nevermind, just had to take the Shipments table out of there and it became a simple full outer join - I can get the shipment info seperate to save a headache. -
Simple SQL statement I can't seem to get right
jenn5175 posted a topic in Database / XML / Reporting
Okay, there may be a very simple answer for this but for some reason I am having difficulty finding it. I need to write a query statement to fill a datagrid (so it has to be one query). Here's a simplified version of my situation. Maybe someone can shed some light on which ways I can join things to make it happen. I have three tables: Shipments, ShipmentItems, ShipmentContainers. The Shipments table holds information about the shipment (i.e. date leave, driver, expected arrival time, etc). The ShipmentContainers table holds all containers going on that shipment (pallets, road cases, etc). The ShipmentItems table holds the actual items being shipped (plasma screen, LCD Projector, etc). Containers may be shipped empty (no Items) and Items may be shipped without being in a Container. Here's my tables: Shipments ------------- *iShipmentID *DateLeave ... ShipmentItems ------------------- *iShipmentItemID *iItemID (from another table) *iShipmentContainerID (set to 0 if not in Container; FK from ShipmentContainers) *iShipmentID (FK from Shipments) ShipmentContainers -------------------------- *iShipmentContainerID *iShipmentID (FK from Shipments) *iContainerID (from another table) I need a query which shows all three things - (1) A listing of ShipmentItems in ShipmentContainers (2) A listing of ShipmentItems not in ShipmentContainers (Container field in datagrid = null) (3) A listing of ShipmentContainers with no ShipmentItems (Item field in datagrid is null) Can anyone help with my SQL statement? I have tried every different join I know and am stumped. Because of the whole triangular relationship going on its not straightforward. I'm thinking I have to create temp tables and nest some select statements but my eyes are bugging out from looking at it - HELP! Jenn -
PlausiblyDamp - not sure if you quite understood my issue. Say I have three tables: tMainCategories ---------------------- iMainCategoryID sMainCategoryDesc tSubCategories -------------------- iSubCategoryID iMainCategoryID sMainCategoryDesc tEquipmentItems ---------------------- iEquipmentItemID iSubCategoryID sItemDesc Now say in my datagrid I want to display all items along with the main category and sub category it belongs to. In my tEquipmentItems I only have the IDs to those but I want to display the main category description and subcategory description alongside each item. There is not one table in my db that holds all of the information I want to display and therefore I was looking for a way to display a SQL statement rather than a table (so I can join them). I have figured out a way to display a joined SQL statement but cannot figure out how to (a) Name the columns myself (it uses the field name) and (b) Make the columns appear directly on load rather than having to manually click the "+" and then the word "table". Any advice? Jenn