Click here to Skip to main content
16,008,175 members
Home / Discussions / Database
   

Database

 
AnswerRe: How to find number of student Pin
partyganger22-Jul-04 17:28
partyganger22-Jul-04 17:28 
GeneralRe: How to find number of student Pin
DotNet22-Jul-04 17:50
DotNet22-Jul-04 17:50 
GeneralRe: How to find number of student Pin
partyganger22-Jul-04 18:18
partyganger22-Jul-04 18:18 
AnswerRe: How to find number of student Pin
Bill Dean23-Jul-04 8:57
Bill Dean23-Jul-04 8:57 
GeneralRe: How to find number of student Pin
DotNet24-Jul-04 0:07
DotNet24-Jul-04 0:07 
Generalmutiple ODBC help!!! Pin
Member 123981322-Jul-04 16:34
Member 123981322-Jul-04 16:34 
GeneralRe: mutiple ODBC help!!! Pin
Small Rat23-Jul-04 18:52
Small Rat23-Jul-04 18:52 
QuestionCan't get value from DataSet into variable without explicit casting? Pin
ThomasH122-Jul-04 13:17
ThomasH122-Jul-04 13:17 
Hey guys, got a question for you all! I've got a DataSet/DataTable, created by using a DataAdapter.Fill call. I'm writing a C# class that handles all the ADO.NET work I need, and a different class will call the public methods of this class.

So; I've created the two public properties I need- Public String _custId and Public DateTime _orderDate. But, I can't get the values out of the DataSet/DataTable/DataColumn without doing (in my mind) useless casting! For instance, this doesn't work:

_custID = dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0];

I get the message "Cannot implicitly convert type 'object' to 'string' ". To make it work, I have to do:

_custID = (String)dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0];
....or....
_custID = dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0].ToString();

I'm confused as to why? The following line displays "System.String":

Console.WriteLine(dsOrders.Tables["tblOrd"].Rows[iCurrentRow].Table.Columns[0].DataType);

So, shouldn't that mean that I don't have to do anything else? Why do I need to use (String) or .ToString() ?

And I also can't get the DateTime into a variable. Trying

_orderDate = dsHousing.Tables["tblOrd"].Rows[iCurrentRow][1];

gives me "Cannot implicitly convert type 'object' to 'System.DateTime' ". And, again, if I display the value for Columns[1].DataType, it shows me "System.DateTime". Worse, there's no ".ToDateTime()" method of the Column object, so the only way I can get the DateTime field out is to cast it to a string, and then convert it back to a DateTime. Compared to my problem with the String column, I'm doing twice the un-necessary work just to get the DateTime column!

Is this really what's supposed to happen? If the DataType shows string, why do I need to perform an explicit conversion from object to string? It seems like I'm doing un-necessary work; if the value is stored as a certain datatype, I should be able to pull it out of the DataTable and put it into a variable of the same type.

I even toyed with the idea of .NET assuming I wanted the DataColumn being put into a String- but I can't find a property of DataColumn that just gives me the value. In classic ADO, there was a Field object, which had a Value property. I can understand "DataColumn" being an object, but is there a specific property for pulling the value out of DataColumn? For instance, if those code samples I just gave would be in classic ADO, I would be trying to say _CustID = rs.Fields(x).Value.

Oh I'm using VS 2003.NET EA, with WinXP, .NET 1.1, and have "Using System.Data" and "Using System.Data.OracleClient" at the top of my C# class definition. At first I thought this might be Oracle related, but DataSet/DataTable/DataColumn is part of the System.Data namespace.

Thanks!

-Thomas
GeneralParsing, Processing, And Inserting Multiple Records Into a Database Design Question Pin
Member 66660722-Jul-04 10:47
Member 66660722-Jul-04 10:47 
Generalstore a c# byte array Pin
pelos22-Jul-04 6:38
pelos22-Jul-04 6:38 
GeneralRe: store a c# byte array Pin
partyganger22-Jul-04 17:30
partyganger22-Jul-04 17:30 
GeneralRe: store a c# byte array Pin
pelos22-Jul-04 23:41
pelos22-Jul-04 23:41 
GeneralRe: store a c# byte array Pin
Anonymous23-Jul-04 9:29
Anonymous23-Jul-04 9:29 
GeneralRe: store a c# byte array Pin
partyganger23-Jul-04 9:30
partyganger23-Jul-04 9:30 
Generaldatagrid Pin
viviansm21-Jul-04 21:26
viviansm21-Jul-04 21:26 
GeneralRe: Very Urgent SQL query Pin
ThomasH122-Jul-04 13:20
ThomasH122-Jul-04 13:20 
GeneralRe: Very Urgent SQL query Pin
partyganger22-Jul-04 18:23
partyganger22-Jul-04 18:23 
General"how to install multi database on the same machine using different names from DTS package" Pin
Harmeet Singh21-Jul-04 17:28
Harmeet Singh21-Jul-04 17:28 
GeneralSQL Table Names in the Header Pin
Cedar Sith21-Jul-04 11:55
Cedar Sith21-Jul-04 11:55 
GeneralRe: SQL Table Names in the Header Pin
Bill Dean23-Jul-04 9:14
Bill Dean23-Jul-04 9:14 
GeneralLooking for some code that imports a CSV file using ADO.NET Pin
David Flores21-Jul-04 11:09
David Flores21-Jul-04 11:09 
GeneralSQL Server engine? (packaging) Pin
xstoneheartx21-Jul-04 10:50
xstoneheartx21-Jul-04 10:50 
GeneralRe: SQL Server engine? (packaging) Pin
Anders Molin22-Jul-04 16:09
professionalAnders Molin22-Jul-04 16:09 
GeneralA Challenging SQL Server Puzzle Pin
partt21-Jul-04 6:31
partt21-Jul-04 6:31 
GeneralRe: A Challenging SQL Server Puzzle Pin
Steven Campbell21-Jul-04 7:09
Steven Campbell21-Jul-04 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.