Ketsuekiame 860 Master Poster Featured Poster

If you check your other thread I've already told you what the problem is. For the sake of argument, I'll repeat myself.

Calling getline is overwriting your text variable with each loop. Therefore, when you press enter twice, text contains the character '32' (Which represents Enter)

When you get your data into text, you need to store it somewhere that it won't be overwritten.

Ketsuekiame 860 Master Poster Featured Poster

The error means that it cannot update the database with the data it's been given. So that suggests that you have a problem with the contents/design of your database.

Is there a Foreign Key constraint that becomes invalid if you try to use this data?

Ketsuekiame 860 Master Poster Featured Poster

Well, as the txt file is non-executing, you will need to decide what program you wish to open it with.

You can then open the programs using CreateProcess using the correct parameters.

If your lecturer didn't know how to do this, I would be worried...

little_grim commented: Gave me a great site for C++ information +0
Ketsuekiame 860 Master Poster Featured Poster

Have you checked the connection string?

Ketsuekiame 860 Master Poster Featured Poster

As you're just beginning C#, I suggest you get the following.

Professional C# 2008

or

Beginning Microsoft Visual C# 2008

Ketsuekiame 860 Master Poster Featured Poster

Ah, I didn't think MS SQL supported an empty column list. It appears it does, provided you get the order correct and it has an identity column.

The second point is that after you have created your command, you need to execute it.

On line 19, you create the command. But then it doesn't do anything with it =)

Ketsuekiame 860 Master Poster Featured Poster

If you have queries make threads. This is a community site so keeping potential help from other people is something I don't agree with =)

To know more from here there's a lot of tutorials on the web that can help you. Or you can get a decent programming book from Amazon or your local shop.

Ketsuekiame 860 Master Poster Featured Poster

Yeah pretty much.

The Person has "Name" and Fireman has inherited Person. So all of the Person class (that hasn't been marked private) is available to Fireman. public String Name; is accessible to Fireman
If we added a private variable to Person called PersonId... private int PersonId; is NOT accessible to Fireman

Yes. If you override a function, when you call that class's function. public override void Walk(){ // stuff } When you called Fireman.Walk() that method is run.

You can if you choose, decide to call the base class method instead. public override void Walk() { base.Walk(); } This will call Person.Walk().

You can also cast Fireman to Person...

Fireman sam = new Fireman();
sam.Walk(); // Fireman.Walk();
Person thisPerson = (Person)sam;
thisPerson.Walk(); // Person.Walk();

The above code will only work if Person is not an abstract class.

Ketsuekiame 860 Master Poster Featured Poster

Your insert statement is incorrectly formed.

You need to declare what columns are to be filled before telling it the data.

The w3Schools site will give you a lot of help with SQL Syntax

Ketsuekiame 860 Master Poster Featured Poster

No, I'm not here to do your work for you. If you're not going to help yourself, then why should I?

The error you're having is pretty simple. Stepping through it yourself and thinking about what is happening will lead you to the correct solution.

Ketsuekiame 860 Master Poster Featured Poster

Paste the code you have, then write out in English what you think this code is doing, line by line.

This will help you understand where and what the problem is.

Ketsuekiame 860 Master Poster Featured Poster

It's not skipping, but it's printing out exactly like you asked it to.

You might want to check where stuff is in your while loop.

Ketsuekiame 860 Master Poster Featured Poster

No you got the assignment the wrong way around.

If you still want to use getline(cin, text) Then you would need to then use bob = text;

Ketsuekiame 860 Master Poster Featured Poster

You could make it OO I guess? Something that simple doesn't really need it though but if you want to do it as an exercise, try creating classes for the types of rabbits.

Ketsuekiame 860 Master Poster Featured Poster

while (nl < 2 && getline(cin, text)) If you don't understand what happens here, you are getting the data that you have just typed in and assigning it to the "text" variable. You will continue to do this while nl is less than 2.

So when you type in "Bob" and press enter, "Bob" is assigned to text.
Then on the next iteration, you just press enter. This causes getline to overwrite your text variable with nothing. text is now empty again and the text.empty() is true so nl is incremented by 1.

You need to move the data you entered somewhere so that it isn't overwritten.

Ketsuekiame 860 Master Poster Featured Poster

Yes. You should send data in accordance to which pin you want to set "on".

Your data pins are pin2 to pin9 (making 8 data pins) There are 5 status pins (10, 11, 12, 13 and 15) and 4 control pins (1, 14, 16, 17) the rest are ground.

Your 8 pins can be represented in binary. 0000 0000 starting from the RIGHT is pin2 (or data pin1) so to send data down datapin1 you would send 0x01 to address 0x378.
to turn on datapin8 you would send 0x80.

Sending 0xF2 would turn on 1111 0010 (so pins 8, 7, 6, 5, 4, 2)
Sending 0x03 would turn on 0000 0011 (so pins 1 and 2)

Sending 0x00 would turn off all pins.


Hope this helps.

Ketsuekiame 860 Master Poster Featured Poster

For all you know, the rest of them *could* be nothing, however I believe they're reserved for additional LPT ports, or for the port settings, but I'm not 100% sure

DMA stands for Direct Memory Access. This goes way back to DOS. Everything used to have a different Direct Memory Access number. You could then access the device using the DMA number and it bypasses the processor. It's put into use automatically now using Programmed I/O. (If you didn't use DMA, the processor would have to completely dedicate itself to the task of reading and writing to the port. Slowing down your machine to a near crawl in computing terms)

In the modern Windows OS, everything is mapped into the lower address space and exists in ring0 also known as kernel mode. This is kept separate to User Mode, or ring3, where your apps run. Drivers can re-map kernel mode to user mode and vice versa effectively becoming a proxy.

Ketsuekiame 860 Master Poster Featured Poster

Ok I'll give a quick lesson on classes and inheritance.

(This will come in handy for your PHP as PHP5 and above uses classes also)

If we ignore the fancy definitions for a minute and go back to something more common in English.

Think of a class as an object. Something that is sat on your desk (not the C# keyword).
Your keyboard for example. Let's say we want to make a class out of your keyboard

public class MyKeyboard
{
    Keyboard();
}

The empty Keyboard function you see there is the Constructor. At the moment it doesn't do anything, but it gets called whenever you "make" (instantiate) a keyboard.

So consider what your keyboard is like. It has a colour and it has keys.
So we modify the keyboard class to represent this.

public class MyKeyboard
{
    Keyboard();
    public Colour KeyboardColour;
    public List<String> KeyboardKeys = new List<String>();
}

(If you don't know what a list is, it's like an array, but you can make it grow or shrink as you need to)

As you can see we can now assign the keyboard a colour and give it some keys represented as strings ("Q", "W", "E", "End", "Escape" etc)
Things your keyboard HAS are called Properties and are your individual bits of data that describe your class. A person would have the following properties, Name, Age, Height, Job and then some.

Ok so now consider what can you keyboard …

Veneficae commented: Very helpful post, helping me wrap around code that I'm new to. Thanks again! +1
Ketsuekiame 860 Master Poster Featured Poster

Ok I'll help...


Choose a different course. =/

Ketsuekiame 860 Master Poster Featured Poster

PHP is becoming more OO...It is! Really!...

I know I'm deluding myself ^^

Ketsuekiame 860 Master Poster Featured Poster

tinyint is already unsigned. It is a just a single byte of value 0-255.

A point to remember if you ever need to translate to MySQL is that MySQL stores tinyint as SIGNED by default, whereas MS SQL stores it as UNSIGNED by default.

You can cast between the two in code (providing you do sufficient checks first)

Ketsuekiame 860 Master Poster Featured Poster

I would begin by designing something that could become quite large.

I don't mean full scale design though.

For example. I would treat everything as a GameObject where GameObject has some basic data like "Description", "Position" etc and some basic functionality like "PrintDescription", "Push", "Pull" etc.

Then specify more; so if you had a Banana and a Room.

public class Banana : GameObject
{
    // Still have all GameObject methods etc
    StepOn(){ Console.WriteLine("You slipped on a banana!");
}

public class Room : GameObject
{
    // Still have all GameObjects basic stuff
    public WalkNorth();
    public OpenDoor(int doorNumber);
}

etc etc.

This way you can componentise just about every aspect, meaning less repeated code.
(eg. you only have one PrintDescription method rather than 20 with different text in)

I would bear this in mind when you start coding it again =)

Antenka commented: Good job. Stimulating newbies to prevent the coding with desing would save a lots of time :) +2
Ketsuekiame 860 Master Poster Featured Poster

tnks for your replies!

@katsuekiame, yes you're right, I was trying to access the printer port's memory! I'm trying to learn how to control the printer port so that I can control a primitive flatbed plotter I've built from old printer parts (just for fun)...

@chiwawa10, I was trying to access that specific memory location because I had to access the printer's memory register...

btw, does anyone know what are memory segments?
The thing is, I can access memory addresses very easily with QBasic's peek and poke functions, but before using any of those functions, you have to use the DEF SEG function (QBasic's on-line help defines this function as 'a memory statement that sets the current memory segment address for a subsequent PEEK or POKE function')

so the following code in QB:

DEF SEG = 0
PEEK (888)     '888 is the decimal equivalent of 0x378

is different from this:

DEF SEG = 1
PEEK (888)

I need to know which memory segment I need to use to access the right address...
Tnks again!

DEF SEG gets a segment of memory. In QBasic this is the high-order 16bits from the memory segment you wish to work in.

The peek and poke then works with the low-order 16 bits.

So your code effectively sets the high order segment to work with to 0, and then requests what's being held at memory address 0x378 (888 to hex is 0x378)
The following will read the memory from address 1234ABCD:


       
Ketsuekiame 860 Master Poster Featured Poster

Ok, I think you'll need a file called inpout32.dll

Check this link for all the information you should need

Ketsuekiame 860 Master Poster Featured Poster

Hi there!

Am I correct in assuming you want to access the parallel port?
You may be better using CreateFile("LPT1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);

Then using ReadFile and WriteFile to read and write data over the port using the handle that "CreateFile" generates.

The reason you cannot access it directly is because it exists in an area of memory that User Mode applications are not allowed to access. If you wanted to get access to this specific address, then you *must* write a device driver to do it.

Ketsuekiame 860 Master Poster Featured Poster

Then you'll need to design some decision making to work out which strings go in which array list.

Only you really know the answer to that one ^^

Ketsuekiame 860 Master Poster Featured Poster

Please see the post above your last. That is the correct method.

Remember you can use variables as your key name, they don't have to be quote marked.

string str = "bob";
hashtable["bob"];
hashtable[str];

Choosing either of the above will give you the same result.

Ketsuekiame 860 Master Poster Featured Poster
DbProviderFactory factory =
    DbProviderFactories.GetFactory("System.Data.OleDb");

DataTable userTables = null;

using (DbConnection connection =
            factory.CreateConnection())
{

    connection.ConnectionString = "Provider=Microsoft
        .Jet.OLEDB.4.0;Data Source=" & file;
    
    // We only want user tables, not system tables
    string[] restrictions = new string[4];
    restrictions[3] = "Table";
    
    connection.Open();
    
    // Get list of user tables
    userTables =
        connection.GetSchema("Tables", restrictions);
}

// Add list of table names to listBox
for (int i=0; i < userTables.Rows.Count; i++)
    listBox1.Items.Add(userTables.Rows[i][2].ToString());