darkagn 315 Veteran Poster Featured Poster

Use log4net, it is thread-safe and can log to various different appenders including a text file (RollingFileAppender).

darkagn 315 Veteran Poster Featured Poster

I have never used the WebBrowser control, but my understanding of it was that it was simply a frame for viewing web pages. I believe you need to implement other controls such as a Back button and call the browser's GoBack function when the button is pressed.

darkagn 315 Veteran Poster Featured Poster

Your SQL is attempting to put the value 'False' (as in the string) into a tinyint (which is numeric) column. You need to check the boolean value and assign it to a 0 or a 1. You are converting it to a string by setting it the way that you are. Hint: A more efficient and accurate way to run SQL queries in C# is to use parameters.

darkagn 315 Veteran Poster Featured Poster

Without a WHERE clause in your SQL statement the UPDATE function will change data of every record in the table. I would suggest changing the statement to something like:

Update Lib_member_details set member_name=@member_name,member_address=@member_address,member_contact_number=@member_contact_number,member_email_id=@member_email_id,member_password=@member_password,membershiptype_id=@membershiptype_id
WHERE member_id = @member_id

Assuming that your database table has a member_id column and you can pass that parameter to it. Basically you should add all columns of the primary key of the table to ensure that only one record is updated.

darkagn 315 Veteran Poster Featured Poster

I would put the function in your ShapesDemo class along with the main method. Your main method should basically create a bunch of shapes with different sizes and call the DisplayFigureDetails method on each shape.

darkagn 315 Veteran Poster Featured Poster

I don't think your main method belongs to the GeometricFigure class. The main method should go in the ShapesDemo class instead.

Having said that, your project description tells you to accept a GeometricFigure parameter to a method in which it's figures (height, width, area) is displayed. Your method signature should look like this:

private static void DisplayFigureDetails(GeometricFigure shape)

Then you can call the DisplayFigureDetails method for any class that extends the GeometricFigure class (ie Triangle, Rectangle or Square) by passing in your shape, for example:

Square square = new Square(8, 8);
DisplayFigureResults(square);

Hope this helps :)

darkagn 315 Veteran Poster Featured Poster

I believe that it doesn't (although I could be wrong). However you can extend the class and override those operators to suit your needs.

darkagn 315 Veteran Poster Featured Poster

So what have you come up with so far? We aren't allowed to just hand you code, we need to see some sort of effort...

darkagn 315 Veteran Poster Featured Poster

Rather than AppendLine, use Append. Your variable read contains an endline character since that is how the ReadLine terminates the line.

while ((read = f.ReadLine()) != null)
{
   s1.Append(read);
}
darkagn 315 Veteran Poster Featured Poster

Or if you want to do it in SQL:

SELECT * FROM salesdetail WHERE DATEDIFF(YEAR, Date, CURRENT_TIMESTAMP) = 1
-- OR
SELECT * FROM salesdetail WHERE DATEDIFF(DAY, Date, CURRENT_TIMESTAMP) = 365
darkagn 315 Veteran Poster Featured Poster

The only encryptions worth using are one-way encryptions. C# has a few classes that can do this, the only one I have used is the System.Security.Cryptography.Rijndael class, however you should use AES instead if you need a more secure algorithm. There is lots of sample code on the MSDN website in the documentation for the System.Security.Cryptography namespaces.

darkagn 315 Veteran Poster Featured Poster

To build a GUI, choose Windows Forms Application for the project type. A console application is one that runs on a command line or via a batch file.

You are correct about adding a class.

Your exe file will be created in your bin folder from where you save your project unless you change the properties of your project.

darkagn 315 Veteran Poster Featured Poster

Hi all,

Can someone tell me if this is a delphi bug? I am using a Controls.TDate to store a date and using the SysUtils.EncodeDate function to set the value.

Invoice.DateReceived := EncodeDate(2011, 03, 16);

When I store it in a MS SQL database field, it is adding 2 days to the date when the insert happens.

INSERT INTO Invoices (InvoiceId, DateReceived) VALUES (:InvoiceId, :DateReceived)
// Query is a TADOQuery object
Query.Parameters.ParamByName('InvoiceId').Value := Invoice.Id;
Query.Parameters.ParamByName('DateReceived').Value := Invoice.DateReceived;
darkagn 315 Veteran Poster Featured Poster

Don't get too hung up on which languages you need to learn. It's more about learning problem solving skills, design patterns, data structures and algorithms. I learned Java at university and about 1% of the commercial code I have written has been in Java. Once you know one language, subsequent languages are easily picked up.

.NET is a windows framework that several languages are based on, including C# .NET and Visual Basic (VB) .NET. I had only read a few lines of C# before entering the workforce, now much of the code I write is in C# .NET, but again I must stress that it is not important which language(s) you learn.

As for the detailed architecture of a computer, I think so long as you have a general understanding of how a computer works you will be fine. Unless you wish to work for Intel designing new components, then you might need a more expert depth of knowledge, but for software development a general understanding should suffice. That's not to say that it would hurt to know what's going on under the hood...

I'm not sure what you are trying to ask about the general structure of an OS? Since each OS differs I think that learning the theory behind how an OS operates can't hurt, but I wouldn't stress if you only have a general understanding when you complete your degree.

Personally I think that your degree should teach you skills in design, logic, …

ddanbe commented: Nice explanation. +9
darkagn 315 Veteran Poster Featured Poster

Hi pradvin and welcome to DaniWeb :)

You will need to join your tables to get all of the information that you need. The syntax for a join statement is like so:

-- select which columns you need
SELECT Table1.UnitID, Table1.Quantity, Table2.CostPrice, Table2.SellingPrice
-- from which table
FROM Table1
-- join to the second table
INNER JOIN Table2
-- describe how the tables are related, note that an inner join requires all of the fields in the ON clause to be non-null
ON Table1.UnitID = Table2.UnitID

This is the basic format you will need. I will let you have a play to see if you can work out how to manipulate the above query and get the unit profit.

darkagn 315 Veteran Poster Featured Poster

You are on the right track, except that your delimiter for the split function should be a comma ',' rather than a carriage return character '\r'. Once you have done the split, you will have three values in your split1 array - from unit, to unit and multiplier value. I would create a class to store these values and keep a list of them. Then search your list from the user input to work out which conversion to perform.

darkagn 315 Veteran Poster Featured Poster

Yes you can remove the <T> from the name of the function, like so:

static void foo(this List<T> list, T t)
      {
      ...
      }
darkagn 315 Veteran Poster Featured Poster

There are two ways that you can tackle this problem. Either make the ID field in the table an identity field then read it back after you insert the name, or you can retrieve the biggest ID number and add 1 to it using this value to insert.

darkagn 315 Veteran Poster Featured Poster

What type of join are you using on the tables? Cross joins in particular can be very slow with so many records, are you able to change to inner or left/right outer joins? If not, you could try running three separate select statements and filtering down the result set each time.

If you aren't using a cross join, you might be able to try to step through your stored procedure to see where the hold up is. Open MSSQL Server Management Studio, and start a new EXEC query for your SP. Place a breakpoint and step into the procedure using F11. This might help to identify the section that is taking up the time.

Otherwise, can you post your procedure so we can see what is going on? We may be able to help by looking at it.

darkagn 315 Veteran Poster Featured Poster

Your code should be correct, but you may possibly need to create a new object rather than trying to reuse your key object.

RegistryKey key = Registry.LocalMachine;
var subKey = key.OpenSubKey(location, isWritable); 
// where location is the string of the address for the subkey 
// and isWritable is a bool that specifies whether you are wanting to write to the key (true) or setting it as read-only (false)

EDIT: You may need to create a reference to the Microsoft.Win32 dll in your project. Can you compile your project or does the using statement produce an error?

darkagn 315 Veteran Poster Featured Poster

You can traverse child nodes quite easily in C#.
Example:

// assume here I have a DataSource node called node
foreach (XmlNode childNode in node.ChildNodes)
{
  string nodeValue = String.Empty;
  // use a case insensitive search on the node name
  string childNodeName = childNode.Name.ToLowerInvariant();
  if (childNodeName == "name")
  {
    nodeValue = childNode.Value;
    // do something meaningful with the value of the node...

  }
  else if (childNodeName == "property")
  {
    nodeValue = childNode.Value;
    // do some other meaningful thing with the value of the node...

  }
  else
  {
    // error - invalid node so do some error handling here...

  }
}

Hope this helps.

arjunpk commented: thank you.. :) +1
darkagn 315 Veteran Poster Featured Poster

Try C# using Visual Studio for a windows solution to your needs. C# uses the .NET framework and allows you to design forms and use a code-behind method to handle events, data etc. If you need cross-platform Java has similar capabilities using NetBeans design mode. C++, C# and Java are all based on C-style syntax, so each are similar in terms of syntax.

darkagn 315 Veteran Poster Featured Poster

The easiest way is to store the arrays as properties of a class, then set the data source of your DataGridView to an instance of the class and add columns with the DataPropertyName set to the two properties that you created.

Example:

public class MyContainer
{
  public string[] Items
  {
    get;
    set;
  }

  public string[] Locations
  {
    get;
    set;
  }
}

public class MyForm: Form
{
  public MyForm()
  {
    InitializeComponents();
    MyContainer container = new MyContainer();
    container.Items = InitialiseItems();
    container.Locations = InitialiseLocations();
    myDataGridView.DataSource = container;
    myDataGridView.Columns[0].HeaderText = "Item";
    myDataGridView.Columns[0].DataPropertyName = "Items";
    myDataGridView.Columns[1].HeaderText = "Location";
    myDataGridView.Columns[1].DataPropertyName = "Locations";
  }
}
darkagn 315 Veteran Poster Featured Poster

Rather than using a custom form for this, you can use a MessageBox. Here is a link to the MSDN documentation on this very useful class that can display a message with a set of buttons and an icon. You can use this to determine whether or not the user really wants to quit the application.

EDIT: But if you really want to use your custom form you can use the ShowDialog method instead of the Show method, then check the DialogResult that is returned based on which button the user presses.

darkagn 315 Veteran Poster Featured Poster

You can set the Form's StartPosition property to CenterScreen, CenterParent, WindowsDefaultLocation or WindowsDefaultBounds. Alternatively you can use the Location property of the form to set the X and Y coordinates of the form, in which case the StartPosition property should be set to Manual. Most often in your situation I tend to use the StartPosition.CenterParent option.

darkagn 315 Veteran Poster Featured Poster

The easiest way is to use the Add method of the Items property of the listbox:

myListBox.Items.Add(myObjectToBeAdded);
darkagn 315 Veteran Poster Featured Poster

Oops sorry my mistake!

darkagn 315 Veteran Poster Featured Poster

Hi,

It appears that the code tags in the MSSQL forum aren't working today.

Example: this thread.

darkagn 315 Veteran Poster Featured Poster

The SQL WHERE clause allows boolean logic operators AND and OR. You can combine your statement into one like so:

SELECT * FROM person WHERE lastname = @lastname AND firstname = @firstname AND ID = @id
darkagn 315 Veteran Poster Featured Poster

Hi DoubleJump and welcome to DaniWeb :)

I personally think you should do whichever interests you the most, and only you can answer that. If you can't decide perhaps think about what career are you would like to pursue after you finish your studies and do some research about what sorts of subjects might help you achieve your goal. Perhaps you can talk to a career advisor at your school?

Sorry I can't give you more advice than that.

darkagn 315 Veteran Poster Featured Poster

You can use the BACKUP statement to perform a backup of your database, and a RESTORE to perform a restore of a database. Here is a link to the documentation for MSSQL2008R2 versions of these functions. Post back if you need help deciphering the documentation.

darkagn 315 Veteran Poster Featured Poster

I think the easiest way to stop your thread would be to break out of your while loop in the Reader method on a certain condition.

while (true)
{
  if (shouldIStop())
     break;
  msg = sr.ReadLine() + Environment.NewLine;
  allMessages += msg;
  Invoke(new Action(Output));
  Invoke(new Action(AddNameList));
}

private bool shouldIStop()
{
  // write some code here for the conditions when you want to stop your thread
}

EDIT: Also, once you break out of the while-loop you should probably do a graceful disconnect from the TCP connection.

darkagn 315 Veteran Poster Featured Poster

Not sure if this will work, but I think you could create your own IFormatProvider from the english culture info object and use that when formatting the names of the time zones. Something like (adapted from this post):

public class EnglishFormatter: IFormatProvider, ICustomFormatter
{
  private CultureInfo enCulture = CultureInfo.GetCultureInfo("en"); // use en-US for US English
  public string Format(string format, object arg, IFormatProvider formatProvider)
  {
    return String.Format(enCulture, arg);
  }

  public object GetFormat(Type formatType)
  {
    return (formatType == typeof(ICustomFormatter)) ? this : null;
  }
}

Then you can use this when you add your items to your combo box:

comboBox1.Items.Add(String.Format(new EnglishFormatter(), "{0}", zone.DisplayName);

I haven't actually attempted this so I hope this works for you.

darkagn 315 Veteran Poster Featured Poster

I think we might be over-complicating things. From your original post I thought you were after just the total of the record plus the one that came before it in sequence. If you are after a sum total of all sequences for the record, you can just use the SUM function as I have written in my second post of this thread. There is no need to use subqueries or other functions, the SUM function will give you totals for each record, and you can exclude specific sequenceID's in your where clause if you need to.

darkagn 315 Veteran Poster Featured Poster

Use a left outer join instead of an inner join. Inner joins only return results if both sides return values, left join works so long as the first part returns results, a right join works so long as the second part returns results.

darkagn 315 Veteran Poster Featured Poster

Yes, you need to create the primary key as an identity field. Note that this is only possible for numeric key fields (which you have in this case so that's ok). Simply add the word IDENTITY with the first value and increment values in brackets into your field definition, like so:

CREATE TABLE [dbo].[Computer](
-- this identity will start at 1 and increment by 1 each time...
[Id] [int] NOT NULL IDENTITY(1,1),
[Name] [nchar](10) NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

When you do an insert with an identity field, don't specify the field in the statement. The database will automatically determine the next value to be inserted. One problem that this does present is when rows are deleted the value isn't replaced next time. For example, imagine we insert 10 rows into your table, then delete row 7. When we insert the next row, number 11 is inserted, not 7 to fill the gap. You can use the SCOPE_IDENTITY function to determine the last inserted identity in the database, so if done immediately after an insert you can determine which number was inserted.

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi Suzukaze and welcome to DaniWeb :)

You need to join the tables, the syntax is like this:

SELECT g.GroupName, COUNT(m.MatricNo) AS "Member Size"
FROM Group G
-- join to the MemberOfGroup table
INNER JOIN MemberOfGroup M
-- describe how the tables are related
ON m.GroupID = g.GroupID
-- COUNT function needs a GROUP BY clause to describe how to count
GROUP BY GroupName

You may need to experiment with your join, a left or right outer join might be required if you have nullable fields in either table. You can read up on JOINS here.

EDIT: Actually another problem might be that you have a table called "GROUP" which is a reserved SQL word. MSSQL might be thinking that you are attempting to group by without specifying the table name in the FROM clause. I'm not sure whether MSSQL cares or not about this, but it might be less confusing either way if you are able to change the name of the table.

darkagn 315 Veteran Poster Featured Poster

All totals is much simpler. MSSQL provides a SUM function which can be used to sum groups of totals like so:

SELECT A.PolicyID, B.CompanyID, SUM(B.Total) AS GrandTotal
FROM Table1 A
INNER JOIN Table2 B ON A.RecordID = B.RecordID
GROUP BY PolicyID, CompanyID

Note that this will give you totals by policy id and company id, sequence number is not referenced but I don't think it needs to be?

darkagn 315 Veteran Poster Featured Poster

There are a couple of ways to approach this kind of problem but I prefer to use a subquery in this case. Your query will be the subquery for the larger query, and we will select totals from that based on the SequenceID.

I suspect your query looks something like this:

SELECT A.PolicyID, A.RecordID, A.SequenceID, B.CompanyID, B.Total
FROM Table1 A
INNER JOIN Table2 B ON A.RecordID = B.RecordID

Here is how we can use that as a subquery:

SELECT C.RecordID, C.CompanyID, C.Total + D.Total AS GrandTotal
FROM
(
  -- subquery to get the first total
  SELECT A.PolicyID, A.RecordID, A.SequenceID, B.CompanyID, B.Total
  FROM Table1 A
  INNER JOIN Table2 B ON A.RecordID = B.RecordID
) C
INNER JOIN
(
  -- subquery to get the second total
  SELECT A.PolicyID, A.RecordID, A.SequenceID, B.CompanyID, B.Total
  FROM Table1 A
  INNER JOIN Table2 B ON A.RecordID = B.RecordID
) D ON C.RecordID = D.RecordID AND C.SequenceID = D.SequenceID - 1

This should at least give you something to go on. Good luck :)

darkagn 315 Veteran Poster Featured Poster

I would have one table, Visitor, then have a VistorType column that determines whether you are dealing with a student, employee or volunteer. This way you only have to join to one table from other tables that need to know about visitor information, rather than trying to join to the other three or create some sort of union statement.

darkagn 315 Veteran Poster Featured Poster

No that's not quite right. Take a look again at the signature I used for the Die method.

// not public virtual void Die(), instead:
public int Die()
// but if you want you could do:
// public virtual int Die()

And the property should be simply:

public gamescore Gamescore
{
  get;
  set;
}
ddanbe commented: Very nice! +8
darkagn 315 Veteran Poster Featured Poster

Create a property in your base class to house the gamescore enum like so:

public gamescore GameScore { get; set; }

Then in the constructor of each class, set the GameScore property accordingly, for example:

public MotherShip()
{
  GameScore = gamescore.MotherShip;
}

Then in your Die() method in your base class, you should return the points scored like so:

public int Die()
{
  boundary.Controls.Remove(picture);
  return GameScore;
}

Incidentally, I don't believe that you want to make your Die method virtual.

Hope this helps,
darkagn :)

darkagn 315 Veteran Poster Featured Poster

Do you need to initialise your Matrix temp to contain all 0's before performing your sums? The += operator might cause issues if the double temp.matrix[i,j] hasn't been initialised properly.

darkagn 315 Veteran Poster Featured Poster

Hi prosperr and welcome to DaniWeb,

Unfortunately we aren't allowed to do your homework for you. We need to see that you have at least thought about these questions before we can even give you a point in the right direction. How do you think these questions should be tackled? What have you come up with so far in your solutions?

darkagn 315 Veteran Poster Featured Poster

From MSDN Docs:

The FormBorderStyle, MinimizeBox, and MaximizeBox properties allow you to control whether the form can be minimized, maximized, or resized at run time.

The FormBorderStyle property has an affect on size and location of your form. Sizable is the default setting. Here is a link to the documentation for the property, it may give some clues as to why the form behaves this way when setting this property.

darkagn 315 Veteran Poster Featured Poster

Is the CHM file on the PC running the application or in a network location? A security issue exists where windows will block CHM content when served over a network.

darkagn 315 Veteran Poster Featured Poster

1. A static method belongs to the class, not to an instance of the class, so the instance variables have no meaning in a static context. You need to create an instance of your class in the static method, then access any public instance variables, properties or methods of the instance.

2. I don't really understand what you are trying to do sorry. Without access to your answerReturned method or the Promotion method, I can't really see what you are doing.

NewOrder commented: Thank you +0
darkagn 315 Veteran Poster Featured Poster

Here is a link to the MSDN docs for the System.Math class. Take a look and see if there is any method in there that can help.

darkagn 315 Veteran Poster Featured Poster

This statement is a LINQ statement which selects all members of the list (or enumerable) named patchFiles which meet the condition of the method TryReadPatch (I don't know this method sorry) into an array named allPatches. I'm not sure if C++ makes use of LINQ, try a google search to see what you can come up with.

darkagn 315 Veteran Poster Featured Poster

Not sure if this will help you, but you can use LIKE when trying to match strings in SQL. To take your example:

select * from Customer where FirstName LIKE 'Jim%' AND LastName LIKE '%Sau%'

This will select all customers whose first names start with Jim and last names contain Sau. There are other wildcard characters that you can use in your LIKE statements too.