Sodabread 88 Posting Whiz in Training

Let's try this. When you create your stringbuilder, you immediately append a double apostrophe and then a comma. I'm wondering if an empty set of apostrophes is causing issues. For curiosity's sake, try this:

StringBuilder inAppId = new StringBuilder();

for(int j = 0; j < ServiceList.Count; j++)
{
    inAppId.Append("'" + ServiceList[j].App_Name + "'");
    if(j < ServiceList.Count - 1)
        inAppId.Append(",");
}

I'm kind of fishing for a solution here, but I've come across some row return issues when things look like they should work, but there's non-necessary text in the query string.

Sodabread 88 Posting Whiz in Training

Hmm. When you return that SQL command, are you associating it with a connection object? Also, how are you executing the query?

Sodabread 88 Posting Whiz in Training

I'm not 100% on this, but shouldn't your inAppId variable be a stringbuilder or something similar? Right now, you're trying to add a List as a varchar and I didn't think that would implicitly convert correctly.

Sodabread 88 Posting Whiz in Training

What about:

string labelName = "label_" = i.value;
Label temp = new Label();
Label.Name = labelName;
Sodabread 88 Posting Whiz in Training

Sodabread has covered what I intended to.

Yeah, sorry about that, F. I started typing, got up for a couple minutes, got back to my desk and finished the post. I guess I was a couple minutes late =)

Sodabread 88 Posting Whiz in Training

You only need to initialize them in one place, but you may have trouble doing this problem in the fashion you're trying to.

Your second question states that you want to return 2 variables from a function, which is not possible. A void return type means the function returns nothing.

Try declaring the variables in main and pass them to your get function as references, then set their final values in that function.

Sodabread 88 Posting Whiz in Training

Change this and let me know if it works as intended:

if (a1 == 'a1')

to this:

if (a1 == "a1")

If you have more than one character, you need double quotes. Double quotes for strings, single quotes for single characters.

Sodabread 88 Posting Whiz in Training

Well, string would be the variable type you want.

You should be able to use it like this:

std::string x;
std::cin >> x;

If that doesn't work, you can try using:

std::string x;
std::getline(std::cin, x);

The first method should work fine, as it's a single "word" of input. Getline is more for multiple words w/ spaces, at least as far as I've used it.

Sodabread 88 Posting Whiz in Training

It depends on how you want to use the input. Do you want A1 to do one thing and B1 to do an entirely different thing, or do you want A to do one thing, and B to do another, or 1 to do something in addition to A and B, and 2 to do something different in addition to A and B?

Psuedo:

get input

if(input_character == "a1")
     do something
if(input_character == "b1")
     do something else

or

get input

if(input_character == "a")
     do something
if(input_character == "b")
     do something else

if(input_number == "1")
     do something in addition
if(input_number == "2")
     do something else in addition

Also, can the user input more than 1 character or more than 1 number in the same input? That can change how the program needs to work.

Sodabread 88 Posting Whiz in Training

Here's an example for first web apps, then Windows apps.

string str = new string(((Button)sender).ID);
string str = new string(((Button)sender).Name);

Hope that helps.

Omar123 commented: That fixed my problem, thanks +0
Sodabread 88 Posting Whiz in Training

Cast the sender object to a button and check the ID.

Sodabread 88 Posting Whiz in Training

Agreed all around. I need to start posting other suggestions with my solutions =\ My bad.

Sodabread 88 Posting Whiz in Training

Try:

IntegerSet(int a[]);
Sodabread 88 Posting Whiz in Training

I don't know if this would be how you want to do it, but my team in school ordered all variables by byte order, largest (long, double) to smallest (char, bool), followed by variable size (strings, containers, etc...). I'm not sure if it really made a difference in compile times, but it was organized nicely.

Sodabread 88 Posting Whiz in Training

Try:

TextBox6.Text = dr(0).ToString

I don't know VB, so however the syntax is supposed to be I have no clue, but this is the idea.

Because you're only selecting a single field, the reader only has that field, so it's at index 0 as far as the reader is concerned.

amalashibu commented: ya,ur code works well.The error was solved +0
Sodabread 88 Posting Whiz in Training

This is assuming the error is coming from lines 32-37.

Your else statement is inside your if statement's braces. The error is produced by the IDE thinking there's no if statement before the else statement. It should look like the following:

if(check){
     // Do something.
}
else{
     // Do something else.
}

Also, an empty else statement serves no purpose that I know of. If you're not planning on doing any other functionality if the if statement doesn't execute, you don't need that else.

Sodabread 88 Posting Whiz in Training

The way I see your problem, it can be read in two ways. First, either you're not sure how to work with returned variables, or you're misunderstanding what return actually does.

1st understanding:

You need to catch the return from exitFailure and do something with it.

inFile.open(inputFilename, ios::in);
if (!inFile) 
{
	cerr << "Can't open input file " << inputFilename << endl;
	return exitFailure();
}

or

inFile.open(inputFilename, ios::in);
if (!inFile) 
{
	cerr << "Can't open input file " << inputFilename << endl;
	int retCode = exitFailure();
	return retCode;
}

2nd understanding:
Using return only exits the application if you're returning it from main(). If you use return in another function, it's going to return to the function that called the second.

int exitApp()
{
    return 1; // Returns 1 back to main
}

int main()
{
    exitApp(); // Call exitApp function
    
    return 0; // Exits the application and returns 0 to the OS's application layer (don't quote me on that)
}
Ancient Dragon commented: Nice explanation :) +25
Sodabread 88 Posting Whiz in Training
CPotion p2 = *(a.items_[0]); // error: conversion from ‘CItem’ to non-scalar type ‘CPotion’ requested

Don't forget you have to cast your item back to a potion. There are better ways to do this than the way I'm going to show you, as I'm still stuck being a hybrid C/C++ programmer.

C:

// if you want a pointer to the object
CPotion *p2 = (CPotion *)a.items[0];

// if you want the actual object 
CPotion p2 = (CPotion)*a.items[0];

C++:

CPotion *p2 = dynamic_cast<CPotion *>(a.items[0]);

I think that's how the C++ version works. I've never actually used it. I'm beginning to think my school didn't have it quite figured out when they taught us C++.

Sodabread 88 Posting Whiz in Training

Why not just have all items inherit from an 'Item' base class and make a vector of Items? I.E., a helmet is a piece of armor, which is a piece of equipment, which is an item. A healing potion is a potion, which is an item. A +3 vorpal short sword is a sword, which is a weapon, which is equipment, which is an item.

Nick Evan commented: That a step in the right direction +11
Sodabread 88 Posting Whiz in Training

All functions that do not have a return type of 'void' must return a value. To return a value from a function, just do the following:

return variableName;

where variableName is a variable type the same as the return type. This can also be a value, such as:

return 6;

if you're returning an int.

In your main function, where you call the function that should be returning something, you can set a variable to the function such as:

rate = get_pay_rate(Choice);

This will set rate equal to whatever value was returned by the function.

Sodabread 88 Posting Whiz in Training

I'll be somewhere in the Caribbean. 12 night cruise honeymoon. Can't wait.