Sunday, May 10, 2009

How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?

In JAVA I used to use a class which told me where the class was located. I'm trying to tell the application that the database is in the solution but how do i do it?





I've got an OLEDB database, but i dont know how to formulate the connection string. The database is inside the Visual Studio solution but I dont know how to tell it that.





Please help...

How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?
Right click on your solution explorer and select properties. Go to the settings tab, type a name for a new setting (like DatabaseConnectionString) and select [Connection String] as the type. A wizard will popup allowing you to select a database; select your database. From now on, you can access this connection string using the Settings namespace, it would be:





Settings.Default.DatabaseConnectionStr...





I find this method much easier for doing this than remembering how to formulate the connection string. Adding the DB to your application solution really doesn't do anything for connecting to it.
Reply:OLEDB won't give you anything about the connectionstring. You dont really need to know where it is located.


I am using MYSQL database and when installed that MYSQL connector I just added it to each page i needed to work with MYSQL like this:





using MYSQL.data;





this way I get all the classes I need to connect and work with my database.


I hope this helps you


In C# a string is immutable(unchangable) but we have insert()method which insert's a string in between..expln

in c# a string is unchangable if it is created with String class..but in the same class we have a method called string() method which inserts a string in preexisting string...means we are going to change a string it is working properly...so, why we are saying that a string created with a string class is unchangable?

In C# a string is immutable(unchangable) but we have insert()method which insert's a string in between..expln
that's true u can't change a string created with the String class, but the insert() method use the old string and the new string that u want to insert and create a new string, not the old one


C++ programming. My problems are with a String class.?

Good afternoon! :-)





How should I write it correctly?


1st function: void print(std::ostream%26amp; os);


2nd function: static void copy(String%26amp; string1, String string2); (it (I mean the second) copies the matter of string2 to string1)


The private members of the class are: unsigned int elementsNum; and char*pData; .


These were my "small" problems. My "big" problem is that I have to alter my program to be able to treat with UNICODE characters.





So, these (3) are my questions. Only one answer would help me a lot, so if you can answer just one of my questions, it would be lovely.





Thank you!!!





Domonkos

C++ programming. My problems are with a String class.?
(1) will end up being something like:





void String::print(std::ostream%26amp; os)


{


os %26lt;%26lt; pData;


}





3) has an obvious solution but non-trivial implementation - use templates, exactly like the STL has chosen to do. Write and get the class working for chars and then generalize it via templates to wchars and possibly alternate allocators.





2) This is harder to help you with without more info. What are your constructors, copy constructor, overloaded operators, append methods, etc., that you anticipate having in the class?
Reply:Hi,





This link may help you - http://www.jorendorff.com/articles/unico...





Also the book Win32 system programming has excellent explanation and examples on using unicode


http://www.amazon.com/gp/reader/02016346...

flower garden

String class in Turbo C++ 3.0?

I'm using Turbo c++ 3.0 and I don't know how to declare strings for console applications. Can anybody tell me how to make it?





REMEMBER Turbo C++, not Visual C++

String class in Turbo C++ 3.0?
I guess Turbo C++ is ANSI compliant so the normal char should work





Declare as this





char szBuffer[500];





Then use the functions strcpy, strset, sprintf ... on the char array





Is it what you tried ?





Thierry


Why does C++ have a string class when there is already char * (a pointer to type character)?

A string is much more easier to work with than the char * due to the following reasons:


1. You have strict bounds checking in strings; char * doesn't have that.


2. If you need to equate two strings, you can just use the = symbol, not have to call the strcpy function everytime.


3. you can check for equality in an if condition ie u can use == to check if two strings are equal.


4. You can access individual characters by using the .at().


5. You needn't call strlen to check the length. all that need to be called is stringvariable.size().





There are a lot other advantages of using string class too. Ultimately, the string class scores on the ease of use. The char * scores on the raw power that it provides. You can use either depending upon your requirement and the time you are ready to devote to coding.

Why does C++ have a string class when there is already char * (a pointer to type character)?
Char is a single entity.......'a' , '1' etc.





But if u have a collection of characters together....."Bombay","computers"......


That is a string.


the space occupied is more 4 strings whereas character utilises only one byte.





Also way of use 4 chars and strs are different.String handling has a very huge application.However ,it should be noted that a string is an array of characters.


And use is so extensive that use of pointers can be sometimes tedious for the use of strings and is not always convenient and so we deal with string class independently though pointer can be used too.
Reply:char* strings are known as C strings. The usage of C strings is considerably more complex, not least because you have to be aware of memory issues.





With C++ strings for example, you can concatenate strings or place new strings in a string variable with little thought for the underlying memory handling. With char* strings, you better be aware of issues such as null-character termination, having enough buffer space when concatenating, and so on.





In short, C++ strings is a level or two above C strings in abstraction.


What are the major differences between C strings and the string class?

In C, a 'string' is a data type, like an integer or boolean. String variables are stored as sequences of unsigned 16-bit (2-byte) numbers ranging in value from 0 through 65535. Each number represents a single Unicode character. A string can contain up to approximately 2 billion (2 ^ 31) Unicode characters.





In object oriented programming, (C++) a class is a data type that contains 'fields' and 'methods'. Fields describe the class, ie: color, text, name, etc. Methods do something, like print, clear, append, etc. The string class is a class built by Microsoft that comes with C++. It has methods (ie append, concat) and fields (ie length, value) that are useful when dealing with strings.

What are the major differences between C strings and the string class?
I would have to say that Cstrings are better than classes


C++ prog. Problems with a String class. (the same as in my previous question): what's wrong with it? copy fct?

.h::::::::::::::::::::::::::::::::::::::...


#ifndef STRING_H


#define STRING_H


#include %26lt;iostream%26gt;


namespace HomeMadeString


{


class String


{


unsigned int elementsNum;


char*pData;


public:


String()


{


elementsNum=0;


char*pData=NULL;


}


String(String %26amp;theOther);


String(const char* c1);


String(char c, unsigned int times);


~String()


{


delete[] pData;


}


void getStr(char * pBuff);


unsigned int getLength(){return elementsNum;}


void print(std::ostream%26amp; os);


char getChar(unsigned int pos);


static String concatenate(String string1, String string2);


static bool compare(String string1, String string2);


static void copy(String%26amp; string1, String string2);//it copies the second string into the first


};


}


#endif


.cpp::::::::::::::::::::::::::::::::


How to write the "copy" function?


The "print" function?





Please help!





Domonkos

C++ prog. Problems with a String class. (the same as in my previous question): what's wrong with it? copy fct?
You get that char*pData inside your constructor is a separate declaration, it does not reference the class-scope variable with the same name (and it falls out of scope when the constructor returns.





Also, your code is conspicuously lacking any allocations -- don't rely on memory allocated by the caller, it could go away at any time.





More, avoid implementation inside of the .h file, it will bite you in the butt when your projects become complex.





Copying an object is usually done as a self-referential overload of the constructor, accepts parameter of its own class.





Not sure what you want print() to do, print to a printer? Doesn't seem to make much sense. If you mean print to console, what's wrong with printf() or stream output?





Good Luck

edible flowers

Why does C++ have a string class when there is already char * (a pointer to type character)?

Why does C++ have a string class when there is already char * (a pointer to type character)?

Why does C++ have a string class when there is already char * (a pointer to type character)?
the c++ string class is more flexible than just using a char*. I use both depending on how i need to use them.
Reply:A string class can compare a group of characters (sentence, paragraph) while char looks at them individually one at a time.


What is the difference in implementing C/C++ NULL-terminated strings, with the strings in the C++ string class

You may contact a homework helper live at website like


http://homework.ccietutorial.com/

What is the difference in implementing C/C++ NULL-terminated strings, with the strings in the C++ string class
Access methods. 'nuff said.