darkagn 315 Veteran Poster Featured Poster

The problem here is that the @DatabaseName in the command is not an SQL datatype field. You instead need to build your query like so:

public void CreateDatabase(string databaseName)
{
   string query = String.Format("CREATE DATABASE {0}", databaseName);
   // now execute the query using DbCommand or similar class...

}
darkagn 315 Veteran Poster Featured Poster

You need to quote your string N like so:

WHERE p.DATE IS NULL and p.TRUE = 'N'
darkagn 315 Veteran Poster Featured Poster

We aren't allowed to just give you the code (what would that achieve?)

Please show us your attempt and ask any specific questions for any problem that you may be having and we will be happy to point you in the right direction.

darkagn 315 Veteran Poster Featured Poster

You can use class properties to do this. A simple example:

public class MyClass
{
  public string MyProperty
  {
    get;
    set;
  }
}
public partial class MyForm: Form
{
  private MyClass myObject;

  public MyForm()
  {
    InitializeComponents();
    myObject = new MyClass();
  }
  
  public void PassString(string str)
  {
    myObject.MyProperty = str;
  }
}
darkagn 315 Veteran Poster Featured Poster

You need to iterate over your array and write out each one individually. You can do this using a while, for or foreach loop. Have you been shown how to use any of these loops?

darkagn 315 Veteran Poster Featured Poster

You will need a reference to the UserId in your VideoRental class, then when you assign the VideoRental to the User you update the VideoRental object's UserId to match.

Here's how I would do it:

class User
{
  public GUID Id
  {
    get;
    set;
  }
  private VideoRental m_rental;
  public VideoRental VideoRental
  {
    get
    {
      return m_rental;
    }
    set
    {
      m_rental = value;
      m_rental.UserId = Id;
    }
  }
  // ...
}
class VideoRental
{
  public GUID UserId
  {
    get;
    set;
  }
  // ...
}
darkagn 315 Veteran Poster Featured Poster

Hi reemhatim and welcome to DaniWeb :)

There are some pretty strict rules at DaniWeb - we aren't allowed to just do it for you. Have a try yourself and feel free to post questions on specific problems you are having with your algorithm or code and we will try to point you in the right direction.

Good luck :)

darkagn 315 Veteran Poster Featured Poster

Instead of:

object.ReferenceEquals(ctrControl.GetType(), typeof(TextBox))

and the like, you can just do:

ctrControl.GetType() == typeof(TextBox)

Also, where you call your function recursively, I would probably make that inside an else-if rather than a second if-statement. Like so:

if (object.ReferenceEquals(ctrControl.GetType(), typeof(TextBox)))
{
  ((TextBox)ctrControl).Text = string.Empty;
}
else if (object.ReferenceEquals(ctrControl.GetType(), typeof(RichTextBox)))
{
  ((RichTextBox)ctrControl).Text = string.Empty;
}
else if (object.ReferenceEquals(ctrControl.GetType(), typeof(ComboBox)))
{
  ((ComboBox)ctrControl).SelectedIndex = -1;
}
else if (object.ReferenceEquals(ctrControl.GetType(), typeof(CheckBox)))
{
  ((CheckBox)ctrControl).Checked = false;
}
else if (object.ReferenceEquals(ctrControl.GetType(), typeof(RadioButton)))
{
  ((RadioButton)ctrControl).Checked = false;
}
else if (ctrControl.Controls.Count > 0)
{
  ClearForm(ctrControl);
}

Not sure if these small fixes will help fix your problem, as everyone else said it's hard to find the problem with no error message to guide us.

darkagn 315 Veteran Poster Featured Poster

Each node (Unit in your code) in a linked list knows what node follows it, that is the node knows it's "next" node. The lines of this code that you have indicated traverse the list from the start (head) node until we get to the end of the list (when current.next is null), and finally we assign the last node's "next" node to be the new node, effectively adding it to the end of the list.

Hope this helps :)

darkagn 315 Veteran Poster Featured Poster

It might be worthwhile re-posting your question in the C++ forum, someone there may have the answers you seek...

darkagn 315 Veteran Poster Featured Poster

The default application for handling the http protocol is stored in the following registry key:
HKEY_CLASSES_ROOT\http\shell\open\command

You may also need to set the application for other protocols, such as https, perhaps doing some exploration using regedit.exe might provide some answers.

To write to the registry key(s) you will need to look at the Microsoft.Win32 namespace. This tutorial might help to work it out.

darkagn 315 Veteran Poster Featured Poster

In Visual Studio, when you add a class file for your project the access identifier is not specified, but you can (and should) add it. If it isn't specified, it defaults to internal access, which is public within the namespace but private outside it. Java actually does something similar when access modifiers aren't explicitly specified - it's called package access and it makes the class/method/variable public throughout the package but private outside it.

In C# we often use properties for our instance variables that require getter and/or setter methods to give a consistent way of accessing a class's underlying data. There isn't really an equivalent in Java, although other languages, such as Delphi, do have properties. Properties are basically shortcuts to accessing member variables, and there are a number of ways in which they can be used. Consider the following code:

public bool Visible
{
  get;
  set;
}

This is the "pure" form of a property, with public getter and setter method. The equivalent code in Java would be something like:

private bool visible;

public bool isVisible()
{
  return this.visible;
}

public void setVisible(bool isVisible)
{
  this.visible = isVisible;
}

And in fact, that is exactly what the C# code does behind the scenes, but for readablility and conciseness of code I think you would agree that C# is better.

Another way we can use Properties:

private bool visible;

public bool Visible
{
  get
  {
    return visible;
  }
  set
  {
    // value is the key …
darkagn 315 Veteran Poster Featured Poster

In C# there is the concept of namespaces, which (roughly) correlates to a package in Java, although in Java the naming convention matches the folder structure of the compiled .jar file whereas the C# namespace does not have to. Similarly, there is no hard and fast naming rule in C# class-file relationships, but most conventions follow this trend for ease of use. One big difference is the way get__ and set__ methods are written in C# - often properties are used instead. Another difference in syntax (but not really behaviour) is the way in which interfaces are implemented or base classes extended.

Your Java example might look something like this in C#:

using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.Common;

namespace Example
{
  // the : indicates extends and/or implements
  public class MyFrame: Form
  {
    private string name = "C# the son of Java";

    // the : here indicates that the constructor "inherits" the base class constructor
    public MyFrame() : base()
    {
      // ...
    }

    // C# convention - methods and properties start with capital letter
    // instead of Java's camel case of lowercase first letter but capitalises second word, third word etc
    public void PrintMe(string name)
    {
      //...
    }

    private string GetName()
    {
      // although this is legal, in C# you would probably use a property (see below)
      return this.name;
    }

    // Property - outside this class use MyFrame.Name to access the name variable.
    public string Name
    {
      get
      {
        return this.name;
      } …
darkagn 315 Veteran Poster Featured Poster

I'm afraid I'm no C++ guru, but I can probably compare C# and Java:

Some similarities:
- both have system garbage collection (C++ does not - you have to allocate and deallocate memory for objects).
- both have strict compiler conditions which are checked such as array indexes, initialisation of variables before use etc (I believe that C++ only checks syntax, resulting in many run-time errors).
- both have large API's and documentation (Java - http://download.oracle.com/javase/6/docs/api/ , C# - http://msdn.microsoft.com/en-us/library/hfa3fa08.aspx).
- both can perform reflection.
- both have excellent exception handling.

Some differences:
- C# (and C++ for that matter) allows operator overloading, Java does not.
- Java has primitive types such as int, char, double etc. Although C# has a similar syntax, the "primitive types" are actually objects and behave in the same manner in terms of memory usage and referencing.
- In Java, all method parameters are called by value, that is that the values of the parameter variables are copied into method local variables. C# allows call by value by default, but can also pass a parameter by reference, allowing the properties or values of parameters to be mutated. C# also allows an "out" variable, which is a means of returning more than one value from a method.

There are more similarities and differences between the languages. C# and Java are very similar in their syntax, C++ is more like C in …

ddanbe commented: Good answer! +7
Stefano Mtangoo commented: Well explained! +6
darkagn 315 Veteran Poster Featured Poster

Hi flamer_x86 and welcome to DaniWeb :)

PHP can be run via IIS or Apache, however the IIS configuration can be very tricky (IMHO). If you are using Windows OS (I assume you are since you talk of IIS), I would suggest installing xampp which includes an Apache install, MySQL, PHP Admin.

darkagn 315 Veteran Poster Featured Poster

If the $instance variable is null, it is created then returned. If it is not null, it is simply returned without being re-created. Your example is equivalent however. Note that my code does not have curly braces for the if-statement, so only the first line after the condition is skipped if the condition is false.

darkagn 315 Veteran Poster Featured Poster

public static function: this declaration indicates that the function is public so can be called from outside the class (for example, you can call the getInstance function from the session class. The static part of the declaration indicates that it is not called directly by a MYSQLDB instance variable. Instead, you call it like so:

$database = MYSQLDB::getInstance();

Because the constructor and clone functions have been made private, they can't be called from outside the class. This means that the only way to get an object of type MYSQLDB is by calling the getInstance function. This function creates an instance if it hasn't yet been created but if it has it is simply returned. Therefore there can only ever be one instance of the object.

Sorry, there are a couple of errors in my code for the MYSQLDB class, I was getting confused with C# syntax. The corrections are:

// this instantiates a class variable called $instance to a null value
private static $instance = null;
//...
public static function getInstance()
{
  // what we are doing here is checking whether the instance has been created
  // if it hasn't it is created
  if (MYSQLDB::instance == null)
    MYSQLDB::instance = new MYSQLDB();
  // now we return it
  return MYSQLDB::instance;
}

I hope this has helped, please let us know if you are still unsure of what I have described.

darkagn 315 Veteran Poster Featured Poster

Personally I think the best implementation is to use the Singleton design pattern and not the global keyword in this instance. So your code for MYSQLDB class would be:

class MYSQLDB
{
  private static instance = null;
  // private constructor and clone methods
  private __construct()
  {
    // initialise any variables here
  }
  private __clone()
  {
  }
  public static function getInstance()
  {
    // this code ensures there is only ever at most one instance of this class
    if (instance == null)
        instance = new MYSQLDB();
    return instance;
  }
  public function validateLogin($member, $password)
  {
     // check the member/password details in the database...
  }
}

Then in your session class you call the getInstance method to initialise your database accessor like so:

class session
{
  private $database;
  public __constuct()
  {
    $this->database = MYSQLDB::getInstance();
  }
  function login($member, $password)
  {
    // now you can use your database variable like so:
    $this->database->validateLogin($member, $password);
  }
}

I believe this method is cleaner than the global approach, but I'll leave it up to you to decide what's best for your application.

darkagn 315 Veteran Poster Featured Poster

Interfaces are extremely useful, and there are many examples why.

Taking your example one step further, you can then have another class that does this:

public class Copier
{
private ICopy copy;

public Copier(ICopy copy)
{
  this.copy = copy;
}

public void MakeCopy()
{
  copy.CopyMethod();
}
}

Now the Copier class doesn't care how the CopyMethod is implemented. This means that you can decide what gets passed to your Copier object via the constructor, and it could be a FileManipulation object or a MakePrankCalls object, or some other implementation of ICopy interface.

This is just a simple example, but as your classes get more complex, this is extremely useful.

darkagn 315 Veteran Poster Featured Poster

First things first, you can set the version of your application in your Publish properties of the project. Then when you load your program you need to find the executable file (may or may not be in the default install location), then use the File or FileInfo class to check the version attribute. Then you could check against the current safe build version (somehow you need to provide those details, maybe online lookup?)

darkagn 315 Veteran Poster Featured Poster

Not sure if there is an easier way, but you can use Convert.ToInt32(string) method to convert your string to an integer. Here is a link to the MSDN docs on this method which should provide some insight.

darkagn 315 Veteran Poster Featured Poster

The property setting line of _dateID = value is correct, but you never actually set it in your LoadData function, and you should carefully check your Save function too, because sometimes you use _dateID and sometimes you use dateID , which is the parameter to the function and not this.dateID which is the property that references _dateID .

darkagn 315 Veteran Poster Featured Poster

Really all you need is a text editor of some kind. You could try an IDE such as Eclipse PDT as this offers features such as code completion and syntax error highlighting, but you can develop in PHP using any text editor and there are many free ones out there. Good luck!

darkagn 315 Veteran Poster Featured Poster

Instead of:

else
{
  echo "Invalid image type. Please Try again";
}

Try this for more information on why the image is being rejected:

else
{
   echo "Type: " . $visitorimage["type"] . "<br />";
   echo "Size: " . ($visitorimage["size"] / 1024) . " Kb<br />";
   echo "Invalid image type. Please Try again";
}

This way you can tell what the type and size of the image are and you can tell why it is being rejected.

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

You will need a solid understanding of assembler code and compiler construction theory.

darkagn 315 Veteran Poster Featured Poster

I think you may be better off asking the course coordinator straight off rather than us, but in my opinion that course syllabus doesn't make a great deal of mention for why those courses are pre-requisites. I assume that you will be expected to write java code in your lab exercises and probably the term project as well, and data structures are probably assumed knowledge because they form the basis of many algorithms.

I would advise you to talk to the course liaison, explain your situation and find out if they have any advice as to how you can get up to speed in the areas that you are lacking. They may even be able to offer you some sort of extra tutoring or be able to point you in the direction of such services.

Good luck in your studies,
darkagn

darkagn 315 Veteran Poster Featured Poster

Another way of doing this might be to load all usernames into an array, then "implode" the array using a comma separator.

$users = array();
while($user = mysql_fetch_array($result))
   $users[] = $user;

// ensure that there is something in the array
if (is_array($users) && count($users) > 0)
   echo implode(",", $users);

As Lsmjudoka said, there are many ways to do what you want.

darkagn 315 Veteran Poster Featured Poster

Hi brookstone and welcome to DaniWeb :)

You can simply add your where statement after the on statement. So something like this is ok:

SELECT * 
FROM A 
LEFT JOIN B 
ON A.ID=B.FK_ID_A
WHERE A.STATUS = 'ACTIVE' 
AND B.FLAG = 'Y'
-- you can also add an ORDER BY statement here to sort the returned data
darkagn 315 Veteran Poster Featured Poster

If you google "javascript alert" you will find many examples of how to create a javascript alert box.

Your algorithm should follow these steps:
1. Get the entered email address from the form.
2. Validate the email address has a valid format.
3. Use SQL statement to see if the email address exists in your database.
4. Display an error message in an alert if the email does exist.

darkagn 315 Veteran Poster Featured Poster

Hi PonAngel and welcome to DaniWeb :)

What problems are you facing? That's a lot of code to go through without any hints as to what's wrong...

darkagn 315 Veteran Poster Featured Poster

A month that is run over three months in six zones will result in 18 records in the ads_months table. So really you probably want the zone_id to form part of your primary key in that table too? (just a hunch, I'm not sure either). I still think that this is the most efficient way to go in the long run though, because really you are only linking the zone_id back to the month for the ad. If that zone_id was dependent on other things, then it might be wise to consider another table...

darkagn 315 Veteran Poster Featured Poster

Your code looks ok to me, except I think you need to override the paintComponent method in the Tooopi class with the code you have in the tupi method? I can't see where the tupi method is being called at the moment...

darkagn 315 Veteran Poster Featured Poster

Instead of creating a whole new table, I would add a zone_id field (numeric FK) to your ads_months table. Adding your new table is less efficient because you need to link back through the ads_months table for a select anyway, and each insert into the ads_months table would need a second insert into the ads_months_zone table (same for updates).

darkagn 315 Veteran Poster Featured Poster

The answer to your question should always be "Whatever language is best suited to the task at hand." Try not to limit yourself to a single preferred language, instead try to understand that each language has pros and cons and thus are better suited to perform certain tasks than others.

darkagn 315 Veteran Poster Featured Poster

If you mean a new line, then in java it is often "\n".

darkagn 315 Veteran Poster Featured Poster

So is your setup like this:

String variableName = "aVariable";
int aVariable = 670;

And you want to access aVariable through variableName? If that's the case, why do you need variableName?

darkagn 315 Veteran Poster Featured Poster

Don't forget to end your php statements with a semi-colon.

<?php echo $_SERVER['HTTP_HOST']; ?>

I'm not sure if this is your problem though as I thought you would get errors...

darkagn 315 Veteran Poster Featured Poster

Inside your php opening and closing tags you need to echo the $_SERVER['HTTP_HOST'] or whatever, you can't just write it the way that you have. Also, you shouldn't use short tags for opening and closing php, use <?php ?> instead.

darkagn 315 Veteran Poster Featured Poster

Your problem is with your 1/4 and 3/4. In Java, both of these evaluate to 0, not 0.25 and 0.75 as you might be expecting. Division of integers in Java (and many other programming languages) always evaluates to an integer, and the decimal part is simply dropped. So the line:

size=size*(3/4);

evaluates to 0, meaning that on your recursive call, size is not >= 1, so the second square is not drawn.

Try changing the two lines to this:

y=y+(size/4);
size=3*size/4;

That should fix your problems.

darkagn 315 Veteran Poster Featured Poster

Nope, it's not optional. If it were optional in Java another method would be defined, insertString(int, String).

darkagn 315 Veteran Poster Featured Poster

Not sure, but I think you need a third parameter in your call to insertString. The Java API says that insertString takes an int, a String and an AttributeSet parameter, so I would check that first.

darkagn 315 Veteran Poster Featured Poster

Hi lumbeelock and welcome to DaniWeb :)

Your error message has been chopped, but the error relates to when you have tried to create a new Employee, the parameters you have passed in don't match the order of the available constructors. Double check your call to new Employee(...) to see that the parameters are what is expected.

darkagn 315 Veteran Poster Featured Poster

Hi annietabio and welcome to DaniWeb :)

int i, j=0;

All you have done here is tell the compiler that you have an int called i, you haven't given it a value. When you say i<=m, the compiler doesn't know whether this is true, because i could be 0 or 100000 or -56. You need to initialize it to a value.

darkagn 315 Veteran Poster Featured Poster
if($value==(change here at kashmere gate ) || $value==(change here at rajiv chowk ) ||  $value==(change here at yamuna bank )   )

Is that your exact code? If it is, what does "change here at kashmere gate" mean? If it is supposed to be a string, enclose it in quote marks.

darkagn 315 Veteran Poster Featured Poster

Hi billmundry and welcome to DaniWeb :)

Here's a MySQL solution to your problem:

http://forums.mysql.com/read.php?10,257906,258154#msg-258154

Hope this helps you out.

darkagn 315 Veteran Poster Featured Poster

Hi jackieoh and welcome to DaniWeb :)

Not sure exactly what your question means, but if you want to output "%" character to the console you do this:

System.out.print("%");

If that's not what your question meant, please let us know what you are trying to do.

darkagn 315 Veteran Poster Featured Poster

What do you mean by offload?

darkagn 315 Veteran Poster Featured Poster

Actually the syntax would be along the lines of:

select * from users where phoneno is null
darkagn 315 Veteran Poster Featured Poster

There are other options too, Ruby on Rails is hugely popular for example.

BTW if you ask such a question ("Do you like PHP or ASP better?") in a PHP forum, you are likely to get a fairly biased answer :P