darkagn 315 Veteran Poster Featured Poster

AleMonteiro is correct, it should be CommandType.Text. You need to modify your CommandStr variable to be valid SQL. Something like string CommandStr = "SELECT F_Get_Desc(@PDesc)"; and then you reference the parameter as @PDesc like so:

OracleParameter pDesc = new OracleParameter("@PDesc", OracleDbType.Varchar2,128);
darkagn 315 Veteran Poster Featured Poster

Once you have read the file into memory, you should be able to write each line out to the console. If you search for the Console.WriteLine function in your favourite search engine you will find plenty of examples.

Good luck!

darkagn 315 Veteran Poster Featured Poster

ExecuteScalar always returns a single value, so you should use it on any query that is expected to return a single record, single field result set. It's represented as object because its unknown what the correct data type should be but should be converted to whatever data type you expect. You will need to handle DBNull.Value during your conversion when using ExecuteScalar, but in your specific example this probably won't be necessary as your query should always either return an Int32 or throw an SQL exception if a timeout or connection error occurs for example.

Your other option would be to use ExecuteReader. This can be used to return the list of records with one or more fields, and then you iterate over the DataReader's Read() call to read each field from an array by column name or index. But in your example query this would be overkill and I would just use ExecuteScalar instead.

darkagn 315 Veteran Poster Featured Poster

I haven't used telerik specifically before but I wanted to mention that there is absolutely nothing wrong with using a third party to solve outstanding problems with a project. Sometimes it is just more cost-effective (not just in dollar value) to purchase another company's tools rather than trying to solve something yourself. You will need to do your homework on each tool that you use though, but often companies will offer a trial period for their products.

overwraith commented: Thanks for the thoughts. I usually do try to make life easier with third party, but sometimes the stuff is of questionable quality. +3
darkagn 315 Veteran Poster Featured Poster

Looks like your professor has given you a fairly good start on what needs to happen inside that for-loop. Did you have a question that you needed help with?

darkagn 315 Veteran Poster Featured Poster

I'm not sure what you mean by the first question, but I can answer the second.

An abstract function is one that defines a method signature without its body so that it can be overridden in any extending implementing class. I'm not sure which programming language you are using but I will demonstrate with a C# example.

// our base class must be abstract since it will contain an abstract function
public abstract class BaseClass
{
    // this function is abstract
    // it has a signature that says it takes no parameter but returns a boolean value
    public abstract bool foo();
}

// now for an implementing class that extends the base class
public class ImplementingClass : BaseClass
{
    // we override the abstract function from the base class
    public override bool foo()
    {
        return true;
    }
}

// let's do another implementation so we can show the real power later
public class AnotherImplementingClass : BaseClass
{
    // again, we override the abstract function
    public override bool foo()
    {
        return false;
    }
}

static void Main(string[] args)
{
    BaseClass first = new ImplementingClass();
    BaseClass second = new AnotherImplementingClass();
    BaseClass[] list = new BaseClass[] { first, second };

    foreach (BaseClass bc in list)
    {
        MessageBox.Show(bc.foo().toString()); // shows true the first time and false the second time
    }
}
darkagn 315 Veteran Poster Featured Poster

Certainly being able to parse file input into something meaningful is always useful. To make it even more generic, why not use a Stream input instead? That way you can handle any input type (including files, via FileStream) so long as the format is what you expect.

overwraith commented: Good thoughts! +3
darkagn 315 Veteran Poster Featured Poster

In C# a bool method always returns a boolean value. In other languages such as PHP this is not necessarily the case, but since this question was in regards to C# I will answer as such.

I think your question is about personal preference so there isn't really a right or wrong answer. For mine, when checking for true I always omit the == true. I actually think that omitting the unnecessary code improves readability of your code. It is also important that methods and properties have a strong naming convention in your code though.

However when I am checking for false I sometimes use the NOT symbol (for example, !someBool) and sometimes use a more explicit someBool == false depending on the complexity of the algorithm. Sometimes when you are reading code back a few years later it is easy to miss that exclamation mark that indicates a check for NOT, whereas the second method indicates clearly that you are checking for false.

JamesCherrill commented: Good point re checking for false +15
darkagn 315 Veteran Poster Featured Poster

I would suggest moving the required method to a third dll if possible and referencing that dll from both of your existing projects.

ddanbe commented: You did it I guess. +15
darkagn 315 Veteran Poster Featured Poster

Either set them to public or pass them in via the constructor. A third option is to have get public but set private. The syntax for this option is as follows:

public char suit { get; private set; }
public char value { get; private set; }

public Card(char aSuit, char aValue)
{
    suit = aSuit;
    value = aValue;
}

This option means that the card's suit and value can be accessed in a read-only manner from outside the instance.

darkagn 315 Veteran Poster Featured Poster

I could be wrong here, but I don't think the MainForm will accept events such as button clicks until it is finished loading, ie until the Load event completes. Have you tried stepping through your code in the debugger to determine when the Load event completes? Maybe something else in the "some code" section(s) are causing the delay.

Have you looked at a BackgroundWorker to do what you are after instead? I prefer to encapsulate threads that I want to run asynchronously in a BackgroundWorker rather than trying to execute my own threads.

darkagn 315 Veteran Poster Featured Poster

Are you able to run in the IDE debugger and see which line throws the AV error?

darkagn 315 Veteran Poster Featured Poster

Lines 62-64 in login.php don't appear to be doing anything. Can you print the values of the $something variable via var_dump after line 64 and check what is going on?

It's been a while since I used mysql, but I think the while loop should be

while (($something = mysql_fetch_array($result)) !== FALSE)
darkagn 315 Veteran Poster Featured Poster

I don't think you want to close the session in login.php using the call to session_close_write. Also, your session setting is commented out, you will need to set each $_SESSION variable before calling cms.php.

Just a side note on your SQL, you should consider looking into parameterised queries. Your code as written is prone to SQL injection attacks because you pass through your $_SESSION or $_POST variables without parsing them.

darkagn 315 Veteran Poster Featured Poster

Use the SelectionStart and SelectionLength properties to select a particular part of the text and then apply formatting to it.

Example:

richtextbox1.SelectionStart = 30;
richtextbox1.SelectionLength = 10;
richtextbox1.SelectionAlignment = HorizontalAlignment.Left;

will align the substring starting at index 30 of length 10 to the left. I'm not sure how multiple alignments on the same line will work though but I'll leave that for you to test.

darkagn 315 Veteran Poster Featured Poster

Without seeing your code it's a bit difficult, but there are some general rules you will need to be aware of when running in a multi-threaded environment. For example, you will need to exert caution when sharing data between threads. Is the callback to your button click waiting for a variable or object that is instantiated by the other thread?

darkagn 315 Veteran Poster Featured Poster

Is there any InnerException by any chance?

darkagn 315 Veteran Poster Featured Poster

Hi Ahmed_51 and welcome to DaniWeb

So, p is principle, r is rate (in percentage) and n is number of years of the loan. I'm not sure I follow your calculation, but I would think it would be something like (principle x rate x number of years) / (number of months), so your variable named top becomes p * ((100 + r) / 100) * n (don't forget the brackets - precedence matters!) and your variable named bottom is 12 * n.

Consider example of $100,000 loan at 10% interest over 15 years. Total payment is $100,000 x ((100+10)/100) x 15 = $165,000 and number of months in 15 years is 15 x 12 = 180, so monthly repayment is $165,000 / 180 = $916.67 (rounded).

Unless you are attempting some type of compound interest formula?

darkagn 315 Veteran Poster Featured Poster

Your SP has 4 parameters - @Call_LogID, @StarDate, @EndDate and @Log_code and none of them have default values specified but you are only setting 2 in your C# code - @StarDate and @EndDate. You will need to also pass @Call_LogID and @Log_code to the SP if you want to execute it.

darkagn 315 Veteran Poster Featured Poster

Depends on the type of database engine being used, but if you mean MSSQL then there are a lot of tutorials and sample code on the subject. For example, this one describes the process in detail.

Otherwise, try google search for "C# SQL Database".

darkagn 315 Veteran Poster Featured Poster

Some real life examples of stack and queue:

Imagine a person washing dirty plates in a restaurant kitchen. As the waiters clear the tables and bring in the dishes, they stack the plates on top of each other, while the person washing the dishes removes the plates from the top of the stack first. This method is known as first in last out (FILO) and is also called a stack.

Now imagine a line of people waiting to be served at a counter. The person who has been waiting the longest is served first and people arriving in the line are placed at the end of the queue. This is also known as first in first out (FIFO).

There are lots of programming applications for stacks and queues, and they are some of the most common data structures used in modern applications. I'll leave this side of it for you to come up with something ;)

darkagn 315 Veteran Poster Featured Poster

Here is a good approach for displaying an image from a MySQL database using PHP.

darkagn 315 Veteran Poster Featured Poster

Not sure if you can actually track that mouse event but you could handle the FormClosing event instead.

darkagn 315 Veteran Poster Featured Poster

You can use ISNULL or COALESCE to get the first non-null parameter as the result. The ISNULL function takes only two parameters and returns the first non-null as the result, or null if both are null. COALESCE takes a list of parameters and returns the first non-null result, or null if all parameters are null. MS recommend that ISNULL be used when there is only two but COALESCE when there are more than two rather than nested ISNULL statements for performance reasons.

OK, that said, here is how I would re-write your SQL statement to manage what you need.

WITH Times AS
(
    -- leave this part the same
)
SELECT
     EmplID
    ,EmplName
    ,ShiftId As ShiftID
    ,convert(char(5),cast(ISNULL(InTime, '00:00') as time), 108) AS InTime
    , -- and so on

So here for the InTime, we are returning InTime when it is not null, or we are returning '00:00' when it is, then casting it to a Time field and then converting it to a char field. I'll leave you to work out the others.

Hope this helps :)

darkagn 315 Veteran Poster Featured Poster

Hi zaidiSEO and welcome to Daniweb :)

It really depends on what you need to accomplish. C# can be used for a console application, a web application, a windows service, a winforms application, a mobile application, ... the possibilities are almost endless. I'm not sure that one is more important than another but all are possible ;)

darkagn 315 Veteran Poster Featured Poster

Because Shto method is marked as static, you don't need to create a new KlasaDB instance. You do however need an instance of Klasa to pass to the call since it takes it as a parameter.

Something like this:

[Test]
public void Test_Shto()
{
    // set some test data up
    Klasa klasa = new Klasa();
    klasa.ID_Klasa = 3;
    klasa.KlasaViti = 19301;
    klasa.Paralelja = -19;

    // call the static Shto method
    KlasaDB.Shto(klasa); // or KlasaUIRD.Shto(klasa);

    // review the result of the Shto method call
    // ...
}
darkagn 315 Veteran Poster Featured Poster

I think $id3 holds the ID of the user that is logged in. It's $id2 that holds the value of the friend ID which is what you are trying to echo to the screen at that point. I think line 44 in your sample code should be:

echo "<a href='index.php?id=profile&u=".$id2."'>".$rows['friend']."</a>";
darkagn 315 Veteran Poster Featured Poster

If you debug your code, what is the value of j in the line that reads sqlCmd.CommandText = "select cBrandName from brandName where iBno = " + j;? When stepping through your code, also check that the line cbBName.Items.Add(dr["cBrandName"]); is actually being called (ie does your SQL query actually return any results?)

darkagn 315 Veteran Poster Featured Poster

There are a number of different ways to do this. Here is one example, and here is an alternative solution.

darkagn 315 Veteran Poster Featured Poster

You will have a file called Program.cs. This is the execution entry point of your application - or more specifically, the static method called Main in this file is. In this method, one of the last lines of the Main method reads something like:

Application.Run(Form1);

Change Form1 (or whatever form it actually reads in your file) to be the type of form you want displayed as the first view of your application.

darkagn 315 Veteran Poster Featured Poster

Check out this article for a description of several different solutions to your problem.

darkagn 315 Veteran Poster Featured Poster

I would suppress the field so that the numbers are hidden from view, then put a plain text field with asterisks over the top of it.

darkagn 315 Veteran Poster Featured Poster

You can suppress the value in Crystal so that it doesn't show up, but then include it in the totals. That's probably easier than trying to mess with your SQL so that you can get the desired data pulled into the report.

darkagn 315 Veteran Poster Featured Poster

I haven't used MonoDevelop, but looking at their website they support a cross-platform interpretation of C# 3 (which is old given 4.5 was released in 2012 for Windows 8 and Server 2012, and 3 was released in 2006 with Vista and Server 2008). Debugging complex code would be interesting using such a middle manager too.

I believe a better approach would be to run VMWare with a Windows OS. This will give you a much closer experience to C# development than any attempt at trying to make .NET "cross platform" which is not its intended purpose.

darkagn 315 Veteran Poster Featured Poster

I'm not sure that you can develop C# applications on an IOS operating system. The .NET Framework is a Microsoft technology, so C# is not cross-platform like Java or PHP. If you only have access to a Mac, my suggestion would be to install a virtual machine running a Windows OS and use Visual Studio as your IDE (there are Express editions available for free for non-commercial purposes).

darkagn 315 Veteran Poster Featured Poster

The problem is that you were attempting to access a member variable from a static context (ie the Main method). You need to either use variables local to your static method or move the initialisation of the threads to the constructor and instantiate your class as an object first.

darkagn 315 Veteran Poster Featured Poster

To stop it from happening in the future, consider adding a primary key to the table. By definition a PK is not nullable and will help identify the records when they are inserted. For more information on primary keys see this W3Schools page on the subject.

darkagn 315 Veteran Poster Featured Poster

Hi kara1990 and welcome to DaniWeb,

Can you show us what you have attempted so far and let us know where you are having problems? We will attempt to help you if we know what's wrong but need to see some effort on your part.

darkagn 315 Veteran Poster Featured Poster

If you look at your declaration of _list, it is a List of type list2 objects. This means that all objects added to the list must be of type list2 or inherit from type list2. The list1 type inherits from the List<int> type, so it can't be added to the list since it is not a list2 type and it does not inherit from a list2 type.

darkagn 315 Veteran Poster Featured Poster

You can use the lock keyword for this. The basic idea is that you lock a private constant object whenever you read or write from the shared variable. Like this:

public class MyMultiThread
{
  private const Object lockObject = new Object();
  private int sharedVariable;

  public MyMultiThread()
  {
    WriteSharedVariable(0);
  }

  public void WriteSharedVariable(int aValue)
  {
    lock(lockObject)
    {
      sharedVariable = aValue;
    }
  }

  public int ReadSharedVariable()
  {
    lock(lockObject)
    {
      return sharedVariable;
    }
  }
}
darkagn 315 Veteran Poster Featured Poster

You can use pointer types in C# however they are rarely needed. Check out msdn's article on pointer types in C#.

darkagn 315 Veteran Poster Featured Poster

Reverse what you did for login.

darkagn 315 Veteran Poster Featured Poster

You can obtain the client IP address with the following call:

string clientConnection = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString();

where tcpClient is your TCPClient object.

darkagn 315 Veteran Poster Featured Poster

Have you tested the Convert.ToDouble function against the Double.TryParse function? I'm not sure if it's faster, but it is generally the preferred approach as it handles exceptions for you.

EDIT: There is also a TryParse static function for each of the other "primitive" types (Int32, Decimal, Byte etc).

darkagn 315 Veteran Poster Featured Poster

Something like the following query should get you close:

-- need a count of the objects by description and transaction
SELECT Description.Name, COUNT(Item.Name) AS count, COUNT(Transaction.Type) AS [under repair]
FROM Description
-- describe the relationship between the tables by joining
INNER JOIN Item ON Description.DeID = Item.DeID
INNER JOIN Transaction ON Item.IID = Transaction.IID
-- only interested in repair transaction type
WHERE Transaction.Type = 'Repair'
-- because we use aggregate functions, need to describe how to group the aggregations (counts)
GROUP BY Description.Name

Have a play with that query, it may need to be adjusted to get the right results but should give you a start.

darkagn 315 Veteran Poster Featured Poster

Yes you can delete the guest, see MSDN's explanation of a SQL Delete statement.

You need to set the parameters for your update function, see the SqlCommand.CreateParameter function.

darkagn 315 Veteran Poster Featured Poster

So what do you get back instead? You will need to read from the response stream and deserialize the returned JSON into a list using whatever DataContract is being returned to you.

Also, you can check the response.StatusCode to see whether the response is a successful response (ie HttpStatusCode.OK) or some sort of problem occurred (such as HttpStatusCode.Unauthorized).

darkagn 315 Veteran Poster Featured Poster

Your method example creates a new instance of the myClass class EACH TIME it is called, and stores the value of the parameters in its own instance variables. This is thread-safe.

I'm not sure that ALL static methods are thread-safe though. It is possible to access static global variables that are potentially shared by multiple threads from within a static method.

I'm sure there are probably other ways in which a static method could be thread-unsafe but it's late here in Australia and I can't think of another example right now sorry!

Someone please correct me if I'm wrong!

darkagn 315 Veteran Poster Featured Poster
darkagn 315 Veteran Poster Featured Poster

Looks like an encoding issue. Do you know what encoding the HTTP response is in? Something like this will read the response in UTF8 encoding:

using (var reader = new StreamReader(errorResponse.GetResponseStream(), Encoding.UTF8))
{
  string error = reader.ReadToEnd();
  Console.WriteLine(error);
}