376 Posted Topics

Member Avatar for nicklbmx

[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."); } …

Member Avatar for apegram
0
170
Member Avatar for songweaver

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] …

Member Avatar for apegram
2
2K
Member Avatar for akonful

For one, your countDigits method is expecting a string parameter, yet you are calling it without one.

Member Avatar for apegram
0
191
Member Avatar for kanuri1

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 …

Member Avatar for apegram
-2
72
Member Avatar for solomon_13000

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.

Member Avatar for solomon_13000
0
74
Member Avatar for borkoBorule

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 …

Member Avatar for apegram
0
80
Member Avatar for wen30

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 …

Member Avatar for wen30
0
110
Member Avatar for cwarn23

[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.

Member Avatar for GrimJack
0
61
Member Avatar for kevin_mysql

[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]

Member Avatar for apegram
-6
115
Member Avatar for ROTC89

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 …

Member Avatar for apegram
0
252
Member Avatar for DdoubleD

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 …

Member Avatar for apegram
0
185
Member Avatar for JAM1011

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 …

Member Avatar for JAM1011
0
109
Member Avatar for johndoe444

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 …

Member Avatar for apegram
-1
85
Member Avatar for nunos

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 …

Member Avatar for apegram
0
158
Member Avatar for Brick

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 …

Member Avatar for Brick
0
155
Member Avatar for cutie0407

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 …

Member Avatar for apegram
0
687
Member Avatar for tqmd1

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 …

Member Avatar for tqmd1
0
123
Member Avatar for ameltei

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]

Member Avatar for ameltei
0
2K
Member Avatar for word.smith

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 …

Member Avatar for word.smith
0
87
Member Avatar for b1izzard

[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 …

Member Avatar for happygeek
0
301
Member Avatar for vivek4020

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); …

Member Avatar for vivek4020
0
89
Member Avatar for Pari13

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 …

Member Avatar for Pari13
0
131
Member Avatar for kanuri1

[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=" …

Member Avatar for apegram
0
88
Member Avatar for justapimp

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, …

Member Avatar for apegram
0
621
Member Avatar for jbrock31

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 …

Member Avatar for jbrock31
0
313
Member Avatar for mcdt2424

[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]

Member Avatar for mcdt2424
0
77
Member Avatar for Myko17

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]

Member Avatar for apegram
0
98
Member Avatar for sangeeta_ratha

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] …

Member Avatar for apegram
0
773
Member Avatar for RahulV

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) …

Member Avatar for padtes
0
850
Member Avatar for pardeep3dec

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 …

Member Avatar for apegram
0
125
Member Avatar for tqmd1

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]

Member Avatar for sknake
0
186
Member Avatar for scottlafoy

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 …

Member Avatar for scottlafoy
0
100
Member Avatar for wingers1290

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 …

Member Avatar for wingers1290
0
173
Member Avatar for Dukester

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 …

Member Avatar for apegram
0
75
Member Avatar for Ap0ca1ypse

Look into String.PadRight() Example: [CODE] Console.WriteLine("John".PadRight(20, " "c) & "Smith") Console.WriteLine("Joe".PadRight(20, " "c) & "Bloggs") Console.Read() [/CODE]

Member Avatar for Ap0ca1ypse
0
92
Member Avatar for vinnijain

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 …

Member Avatar for vinnijain
0
128
Member Avatar for cromie09

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.

Member Avatar for ssommaro
0
108
Member Avatar for vaultdweller123

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, …

Member Avatar for ankush.mukherje
0
158
Member Avatar for nsjoe

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 …

Member Avatar for sknake
0
988
Member Avatar for Noeli

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) …

Member Avatar for apegram
0
99
Member Avatar for venky9589

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]

Member Avatar for venky9589
0
95
Member Avatar for malloc84

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]

Member Avatar for malloc84
0
110
Member Avatar for abhiwjt

[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, …

Member Avatar for apegram
0
54
Member Avatar for itzshaheer

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 …

Member Avatar for vbdotnetlover
0
151
Member Avatar for TommyTran

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 = …

Member Avatar for apegram
0
1K
Member Avatar for jeeter19

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) { …

Member Avatar for sknake
0
119
Member Avatar for TommyTran

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 …

Member Avatar for apegram
0
107
Member Avatar for chunalt787

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 …

Member Avatar for WaltP
0
192
Member Avatar for igirl

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 …

Member Avatar for igirl
0
107
Member Avatar for pymatio

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().

Member Avatar for pymatio
0
134

The End.