376 Posted Topics
Re: [QUOTE=nicklbmx;1119449] [CODE] // print out each StudentRecord and say whether that Student's gpa is >= or < averageGpa public static void printComparisonReults(StudentRecord[]student, int size, double averageGpa) { if(StudentRecord[theGpa] >= averageGpa) //this line has a problem { System.out.println(" The student record is greater than or equal to the average gpa."); } … | |
Re: OK, that was fun. Anyway, what you're going to want to do is loop until you've met your exit condition, which is determined by the formula your teacher gave you. [CODE] Math.Abs(Math.PI - approxPi) < (0.5 * Math.Pow(0.1, decimalPlaces)) [/CODE] Think of it as something like this (in pseudocode) [CODE] … | |
Re: For one, your countDigits method is expecting a string parameter, yet you are calling it without one. | |
Re: 1) Please work on your thread titles. Be descriptive of the actual assistance you are requesting. 2) Have you even tried to do this? This is something that is fairly trivial, even for a novice. Show us some of your own code, let us see what you might be doing … | |
Re: Two quick options come to mind (a) Make them validate themselves with their password. (b) In lieu of or in addition to including the member ID in the link, include a randomly generated key that is uniquely associated with that member. | |
Re: I'm not sure I get the nature of the question. You can certainly use the exact same code to retrieve the connection string in either a desktop or web scenario. [ICODE]ConfigurationManager.ConnectionStrings["name_here"].ConnectionString[/ICODE] will retrieve the information you need, whether it be in web or app.config. You will probably need to update … | |
Re: The public properties/methods of your user control will be accessible from the control's parent, to whom the instance of the control belongs. So if your control is on Form1, Form1 should be able to call UpdateTreeView(). Your seperate class will not have that type of access, and do you really … | |
Re: [QUOTE=GrimJack;1117377]I believe that the word you meant is 'eve' as in the night before rather than eave as in the edge of the roof.[/QUOTE] Probably depends on how bad your January was. | |
Re: [CODE] Select h.Name as HomeTeam, a.Name as AwayTeam From teams h Inner Join games g on h.code = g.home Inner Join teams a on g.away = a.code [/CODE] | |
Re: Sales tax is a percentage, so you should divide it by 100 somewhere. May as well handle that in the declaration [CODE] float salesTax = 8.25F/100; // or simply hardcode 0.0825f [/CODE] This won't affect your output, but you can also simplify the code on the modified price calculation. A … | |
Re: If I'm interpreting your request correctly, maybe something like this meets your needs. [CODE] for (int i = 1; i <= 5; i++) { var query = (from DataRow dr in dt.Rows group dr by int.Parse(dr["WB" + i.ToString()].ToString()) into ballgroup select new { Ball = ballgroup.Key, BallCount = ballgroup.Count() }).OrderByDescending(ball … | |
Re: I see vbCrLf there, so that part should be covered, really. But I see other issues with your loop logic. You use a For Each and have a loop variable of lvItem, yet you ignore it inside the body of the loop. You declare an integer (i) variable inside the … | |
Re: Your first loop is never going to execute if (a) 0 is equal to msg.source or (b) neighbors[0].status is not equal to EDGE_STATUS_BRANCH By putting those checks in the loop exit condition, if the first element doesn't pass all criteria, the loop exits immediately. (If the first element passed, the … | |
Re: Off the top of my head, I can come up with several database entities to represent a college environment. This only took a couple of minutes to layout, so it can be expanded further and obviously not all fields are represented for each table. [B]Classes[/B] CourseID CourseTitle CourseDescription [B]Teachers[/B] TeacherID … | |
Re: Here's my stab at it. [CODE] Select RIGHT(CONVERT(varchar,abs(-11009)), 2), SUBSTRING(CONVERT(varchar,abs(-11009)),LEN(CONVERT(varchar,abs(-11009)))-3,2), SUBSTRING(CONVERT(varchar,abs(-11009)),LEN(CONVERT(varchar,abs(-11009)))-5,2), CONVERT(DateTime,SUBSTRING(CONVERT(varchar,abs(-11009)),LEN(CONVERT(varchar,abs(-11009)))-5,2) + '/' + SUBSTRING(CONVERT(varchar,abs(-11009)),LEN(CONVERT(varchar,abs(-11009)))-3,2) + '/' + RIGHT(CONVERT(varchar,abs(-11009)), 2)) [/CODE] The first three lines after the select are just me pulling the pieces apart as a proof of concept, the lines starting at CONVERT(DateTime, ... are the relevant … | |
Re: It has been a while since I have worked with the CommandBuilder line of objects, but perhaps you can use the .GetInsertCommand().CommandText method & property to retrieve what the builder is creating for you and display it on the screen so you can determine what issue there may be with … | |
Re: You're not going to join your in-memory datatable to an actual database table with a SQL statement. What you want to do is (pseudocode only, have work to do) is something like [code] 'pseudocode For each row of data in your datatable Get value of "code" Construct SQL statement to … | |
Re: Is your data source queryable? You could try using LINQ. Example: [CODE] Dim samples As New List(Of Sample) 'populate list with Sample objects Dim onCount = (From samp In samples Where samp.Status = "On" Select samp).Count() Dim offCount = (From samp In samples Where samp.Status = "Off" Select samp).Count() [/CODE] | |
Re: All you have to do is take the value of [ICODE]storage[0][/ICODE] once you've split the current [ICODE]inttotal[/ICODE] and do whatever you need with it. Keep in mind that storage[] goes out of scope once you iterate within the foreach loop, so handle the value however you need to within the … | |
![]() | Re: [QUOTE=vaultdweller123;1109561]@naraue: you criticize people like your a super genius... ohhh... your too full of yourself... you think your so smart?[/QUOTE] It's true, though. The answers showed no real understanding at all. They came across as someone who knew some terms they read on Wikipedia rather than someone who had experience … |
Re: Try this. [CODE] static void Main(string[] args) { OleDbConnection connection = new OleDbConnection("your_connection_string_here"); string sql = "Insert Into Table1 (iAddress, Instruction) values (@iAddress, @instruction)"; OleDbParameter addressParam = new OleDbParameter("@iAddress", OleDbType.Integer); addressParam.Value = 1; OleDbParameter instructionParam = new OleDbParameter("@instruction", OleDbType.VarChar); instructionParam.Value = "Test"; OleDbCommand command = new OleDbCommand(sql, connection); command.Parameters.Add(addressParam); command.Parameters.Add(instructionParam); … | |
Re: You also have the calculation being performed in the Page_Load event. Unless you have defined default values within those textbox controls, you're going to get an exception when you first load the page (prior to postback). If there are no default values, move the calculation to the button_click event handler … | |
Re: [QUOTE=kanuri1;1114099][code] Response.Redirect("check availability.aspx?ardate='" & dateofarrival.Text & "' ") Dim ardate ardate = Request.QueryString("ardate") arrivaldate.Text = ardate [/code] [/QUOTE] It is unnecessary to append single quotes around the value you are inserting into a querystring. However, you may want to include a call to Server.UrlEncode for the value. [CODE] Response.Redirect("check availability.aspx?ardate=" … | |
Re: Another way to read that is to use LINQ to XML (System.Xml.Linq). [CODE] string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><string xmlns=\"http://tempuri.org/\">6264021</string>"; XDocument document = XDocument.Parse(xml); XNamespace tempuri = "http://tempuri.org/"; var result = document.Element(tempuri + "string").Value; Console.WriteLine(result); [/CODE] Same number of lines to retrieve that simple value as the previous method, … | |
Re: Here is something that will get you 1 MB exactly, although someone else might do it better. [CODE] Sub Main() Dim megabyte As Integer = 1024 * 1024 - 1 Dim buffer(megabyte) As Char For i As Integer = 0 To buffer.Length - 1 'just to vary the output If … | |
Re: [CODE] Select * From Events Where (FromDate >= '01/01/2010' And FromDate < '02/01/2010') Or (ToDate >= '01/01/2010' And ToDate < '02/01/2010') [/CODE] | |
Re: Consider closing the program after the loop. [CODE] Do Attempt += 1 Inputpassword = InputBox("Enter password. This program will close after 3 incorrect attempts. This is attempt number " & Attempt) Loop Until (Inputpassword = Password Or Attempt = 3) If (Inputpassword <> Password) Then Me.Close() End If [/CODE] | |
Re: There are a number of different methods you could employ to arrive at the total, but here is a base which includes one such method. [CODE] <asp:Repeater ID="rptrDemo" runat="server" OnItemDataBound="rptrDemo_ItemDataBound"> <ItemTemplate> <asp:Literal ID="litValue" runat="server" /><br /> </ItemTemplate> <FooterTemplate> <br /> <strong>Total:</strong><br /> <asp:Literal ID="litTotal" runat="server" /> </FooterTemplate> </asp:Repeater> [/CODE] [CODE] … | |
Re: This is more befitting of a report, but it's mostly doable and could be all doable if someone tweaks it a bit. The following assumes a Sales table with CustID, Items, Cost, and ExtraCharges fields. [CODE] Select CustID, Items, Cost, ExtraCharges From Sales Union Select CustID, 'Subtotal' as Items, Sum(Cost) … | |
Re: Add a call to Randomize() before the process that begins the creation of the random numeric string. Example: [CODE] Randomize() For i As Integer = 0 To 10 Console.WriteLine(Rnd()) Next Console.Read() [/CODE] Without Randomize() in the above example, you would get the same 10 values if you ran the program … | |
Re: Trim(value) is being evaluated before IIF(IsDBNull()) and is causing the exception. I would suggest altering your code to something like this: [CODE] Dim temp as String = IIf(IsDBNull(dt.Rows(i)("tittle")), " ", dt.Rows(i)("tittle")) Me.DataGridView1.Rows(i).Cells(1).Value = Trim(temp) [/CODE] | |
Re: Your preferred code should work as intended, have you tried it? In a constructed example on my end, it works fine. I've included a lambda version and a delegate version to match your own method. [CODE] static void Main(string[] args) { List<Inspection> inspections = new List<Inspection>() { new Inspection("Basic","A"), new … | |
Re: You don't need two databases, you need one database with two tables. One would be a Person table (or whatever you want to call it) where you store the relevant personal details (name, country, etc.) and the other would be a PersonEncounter (or whatever you want to call it) where … | |
Re: providerName is an attribute you can use on a connection string item in Web.Config. However, it looks like you are using appSettings instead. [CODE] <appSettings> <!-- your app settings --> </appSettings> <connectionStrings> <add name="theConnectionName" connectionString="yourConnectionString" providerName="yourProvider"/> </connectionStrings> [/CODE] (connectionStrings were introduced with 2.0, so if you're working with a 1.1 … | |
Re: Look into String.PadRight() Example: [CODE] Console.WriteLine("John".PadRight(20, " "c) & "Smith") Console.WriteLine("Joe".PadRight(20, " "c) & "Bloggs") Console.Read() [/CODE] | |
Re: If you plan on distributing an application but want to keep a centralized database, you would not want the clients to connect directly to that database. Host your database and get a web site, then look into web services where the client applications request information and your web service delivers … | |
Re: I have a solution here, but this sounds like homework. Post your code and we'll see if we can tell you where you could improve it. | |
Re: It's only the end of the world if you're Mayan. For the non-Mayan amongst us, life will continue as scheduled. Until June 17, 2023, when the secretly known asteroid slams into northern Russia and incinerates millions in a split second and freezes/starves the rest of within months, that is. Yeah, … | |
Re: I think your delegate invocation is fine. I've produced a slimmed-down version of what you're doing there, and I am not having an issue with the receiveFunc event hander. [CODE] class Program { static void Main(string[] args) { frmChat frm = new frmChat(); Console.Read(); } } public partial class frmChat … | |
Re: Dates (including times) and strings need to be enclosed in single-quote delimitters. So with a table with the following fields Table: Person Columns: LastName - varchar(20) FirstName - varchar(20) Age - int DateAdded - DateTime A SQL insert statement would look like [CODE] Insert Into Person (LastName, FirstName, Age, DateAdded) … | |
Re: You may want to explore the System.Diagnostics.EventLog class. Sample: [CODE=C#] System.Diagnostics.EventLog[] logs = EventLog.GetEventLogs(); foreach (EventLog log in logs) { foreach (EventLogEntry entry in log.Entries) Console.WriteLine(entry.Message); } [/CODE] | |
Re: To write to a text file, use the [ICODE]System.IO.StreamWriter[/ICODE] class. Example usage below: [CODE] String fileName = @"C:\Temp\myfile.txt"; System.IO.StreamWriter writer = new System.IO.StreamWriter(fileName); writer.WriteLine("Writing a line to the text file"); writer.Close(); // closing the file writer.Dispose(); // cleaning up resources [/CODE] | |
Re: [QUOTE=abhiwjt;1108994]please tell me how two dates can be subtracted in asp.net[/QUOTE] DateTime.Subtract(DateTime) will give you a TimeSpan object, from which you can extract the difference in days, hours, minutes, etc. DateTime.Subtract(TimeSpan) will give you another DateTime that will be the old date minus whatever time you indicated. And, of course, … | |
Re: I don't see anything specifically wrong with your SQL statement, although I would caution against going directly to the database with unfiltered string content. Explore parameterized queries or, at minimum, escape single quotes in your strings (by replacing a single quote with 2 single quotes). What about your connection and … | |
Re: You are declaring intnumber inside the body of the loop. This is a matter of scope. Take a look at this [code] Public Class Car Dim mass As Integer Public Sub Drive() Dim speed As Integer For velocity As Integer = 1 To speed Dim force As Integer force = … | |
Re: Here's a convoluted example of creating an event that monitors a property in a class and then subscribing to it. [CODE] class Program { static void Main(string[] args) { ValueHolder valueHolder = new ValueHolder(); valueHolder.ValueChangedEvent += new ValueHolder.ValueChangedEventHandler(valueHolder_ValueChangedEvent); valueHolder.Value = 7; Console.Read(); } static void valueHolder_ValueChangedEvent(object sender, ValueChangedEventArgs e) { … | |
Re: Look at the following line: [CODE] intpos = strname.IndexOf(" ") [/CODE] Then you use that value for your substring function [CODE] strnew = strname.Substring(Val(intpos), 2) 'Locate the last name's first letter [/CODE] Do you see what you are doing there? Outside of making an unnecessary Val call (Substring's first parameter … | |
Re: The main blog I follow is Eric Lippert's "Fabulous Adventures in Coding." [url]http://blogs.msdn.com/ericlippert/default.aspx[/url] He is on the C# compiler team and posts about various things related to C# and other topics, often going into corner cases and explanations on why the compiler might make a decision the programmer would not … | |
Re: If you created the new table to match the fields of the query exactly, so you would have a new table something like this Table: CoursesNew Columns: CourseID, Title, Description, Objectives, Price, Length, Prerequisites, CategoryID, TypeID, SubTypeID, Type Then you could modify the SQL statement provided by darkagn to insert … | |
Re: I assume the files have numeric extensions? Path.GetExtension(fileName) is going to give you the extension, including the period. You're going to want to strip off the first character of the result before going to long.Parse(). |
The End.