There is a very obvious mistake that you are making here. The query myQuery is returning you only one column per row. You are using dataReader.GetTime(1) , which is trying to get the second column (indexes are zero based, not 1 based) and hence generating an index out of range exception, because there is nothing at the "1" ordinal.
Change the line
classStartTime = dataReader.GetTime(1).ToString();
classStartTime = dataReader.GetTime(0).ToString();
The problem may be to do with your use of GetTime(int). The documentation of this states "Gets the value of the specified column as a System.TimeSpan object". Im thinking what you actually want is GetDateTime(int).
However, as with my post above, if all you need is a string, then use GetString(int)
hey hi, The question i want to ask you is that I want to add items in a Combo Box. First of all how would I add items in it? . and Secondly, with every selection of the combo box item, my program should perform following actions:
1) When user selects option "2" from the combo box then the two "Text Boxes" should appear, Similarly if user selects option "3" then three "Text Boxes" should appear.
2) At the bottom of the page is the "Browse" button, which should upload the picture and display it at the "Picture Box" which is displayed just infront of that button.
I'm a bit new to Regex, and almost got this working, except for a small glitch. I have a string called entityName which looks like "120 PP (V987) XYZ", from which I have to strip out the entity code which in this case is (V987). The entity code is V or C followed by any number of digits, all of which is enclosed in ().
My code looks like this:
Regex regex = new Regex(@"^(.*)(\([V,C]\d+\))(.*)");
entityNameString = regex.Split(entityName);
foreach(string s in entityNameString)
Console.WriteLine("\t" + s + "\t\t" + s.Length);
Unfortunately, when I run it, the output produced is
120 PP (C987) ERT
0120 PP 7
It produces an extra null string at the beginning and the end. I'm guessing my Regex pattern is incomplete. How should I correct this?
That is because you are splitting on pattern that matches the entire string.
Let's go for a simple example: If you have a pattern like "(ell)" and split the string "hello" using that pattern, you will get three strings; "h", "ell" and "o". If you have a pattern like "(hello)" and split the string "hello", you will also get three strings; "", "hello" and "".
Make the pattern match only the "(C987)" part of the string, and you get only three strings in the result.
I need to know that can I write rtf text in word document. Actually I have a Richtextbox on my form. Now i need the rtf of that control to be in a word file. Is it possible. If yes............How?
The only way I've found for this so far is to use the clipboard.
Paste your RTF to the clipboard (probably saving the clipboard contents before doing so) and then call Paste on the Selection object you want your RTF to appear in.
Afterwards restore the clipboard contents.
If anyone has a better solution, I'd be interested in that, too.
-- Black holes are the places where god divided by 0...
My advice would have been to go into "Customize Toolbox" and look for "Microsoft Word" component under the "COM Components tab. But looking there, I see that Word has not been included. Apparently, Microsoft does not want us to have this feature?
Right now I am using the following code to open a directory for exploring.
I do believe there must be some one line code available to do the same task. If it is true, then would you please let me know.