|
Thanks. Looks like a good start for me!!
_____________________________
...and justice for all
APe
|
|
|
|
|
I have a dll file written by C++ MFC. I want to use it in C#, but I can't know how to use it. Who can show me how to use it?
Thanks a lot!
|
|
|
|
|
using System.InteropServices;
[dllImport("yourDll")]
public static extern type function(params);
Aaron
|
|
|
|
|
Hi,
I'm writing an application in c#.net and i'm completely new to it.
Please refer to the following code in which i'm getting an exception...
//.....................................................................
String classStartTime;
conn.Open();
String myQuery = "Select starttime from tblecture";
OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(myQuery, conn);
OdbcDataReader dataReader = myCommand.ExecuteReader();
try
{
while (dataReader.Read()) //exception
classStartTime = dataReader.GetTime(0).ToString();
}
finally
{
dataReader.Close();
conn.Close();
}
//.....................................................................
I'm getting this exception for only column named "starttime"; for other fields this code works fine.
Is there any other way to read a field of type time from database?
Thanks,
Kranti
-- modified at 4:13 Wednesday 19th April, 2006
|
|
|
|
|
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.
Solution:
Change the line
classStartTime = dataReader.GetTime(1).ToString();
to
classStartTime = dataReader.GetTime(0).ToString();
|
|
|
|
|
In addition to the above, if your variable "classStartTime" is of type DateTime (as it should be) then you do not need the .ToString() call - it will cause an invalid cast exception.
if classStartTime is a string:
classStartTime = dataReader.GetString(0);
if classStartTime is DateTime:
classStartTime = dataReader.GetTime(0);
|
|
|
|
|
The first field has index 0, not 1.
---
b { font-weight: normal; }
|
|
|
|
|
even when i make it as ...
//...................................................
while (dataReader.Read()) //exception
classStartTime = dataReader.GetTime(0).ToString();
//...................................................
it generates the exception at the previous line i.e. the line containing "while", before going for this statement
Thanks,
Kranti
|
|
|
|
|
What is the exception generated?
|
|
|
|
|
the exception generated is "Array index out of bounds"
|
|
|
|
|
Array Index out of bounds was when you were trying to read element 1, that exception is unlikely to be being generated by the call to while(reader.Read()).
try posting the complete code, that is the relevant bit that is opening connection, creating command etc.
|
|
|
|
|
the complete code is as follows ...
//..................................
String connectionString = "Dsn=pgTEducation;database=teducation;server=192.168.0.135;port=5432;uid=divinet;readonly=0;protocol=6.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;socket=4096;unknownsizes=0;maxvarcharsize=254;maxlongvarcharsize=8190;debug=0;commlog=0;optimizer=1;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;byteaaslongvarbinary=0;useserversideprepare=0";
OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connectionString);
String classStartTime;
conn.Open();
String myQuery = "Select starttime from tblecture";
OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(myQuery, conn);
OdbcDataReader dataReader = myCommand.ExecuteReader();
try
{
while (dataReader.Read())
classStartTime = dataReader.GetTime(0).ToString();
}
finally
{
dataReader.Close();
conn.Close();
}
//..................................
thanks,
Kranti
|
|
|
|
|
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.
regards,
noman
|
|
|
|
|
|
how to use google earth api's in my c# code
|
|
|
|
|
How we transfer a table from dbf to sql server 2000 through programming in c# with table schema plz send me at soni_linux@yahoo.co.in
Vinod Soni
|
|
|
|
|
Hi all,
Would like to know how to export the contents of a datagrid to a SQL 2000 db...(with the code as well , if u plz).......
Thx.
-- modified at 6:09 Wednesday 19th April, 2006
|
|
|
|
|
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:
string[] entityNameString;
Regex regex = new Regex(@"^(.*)(\([V,C]\d+\))(.*)");
entityNameString = regex.Split(entityName);
Console.WriteLine(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
0
120 PP 7
(C987) 6
ERT 4
0
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?
Thanks in advance.
Cheers,
Vikram.
I don't know and you don't either.
Militant Agnostic
|
|
|
|
|
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.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa, thank you very much!
Cheers,
Vikram.
I don't know and you don't either.
Militant Agnostic
|
|
|
|
|
It really doesn't look like you actually want to be splitting the string at all.
if you try this:-
Regex regex = new Regex(@"^(.*)(\([V,C]\d+\))(.*)");
Match m = regex.Match(entityName);
if (m.IsMatch)
Console.WriteLine( m.Groups[2].Value);
Furthermore, your regular expression could be optimised a little - many of the brackets are unnecessary:-
^.*(\([VC]\d+\)).* should work also. Note the the submatch group number as used in my above code will be 1 for this pattern.
And if you move your submatch brackets a bit, like this,
^.*\(([VC]\d+)\).* then your submatch for the string "120 PP (C987) ERT" will contain "C987". I am of course making a wild assumption here that you don't want the brackets in the output.
Incidentally, I didn't test the above code or patterns, but they're good in substance even if they have minor errors in.
using System.Beer;
|
|
|
|
|
Hello all!
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?
Please help me in this regard
Thanx in Advance
Mubashir
|
|
|
|
|
Hi!
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.
Regards,
mav
--
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?
Roy.
|
|
|
|