Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataView/DataSet/DataReader
Message
De
08/01/2007 10:29:40
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
08/01/2007 10:18:06
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01183234
Message ID:
01183448
Vues:
58
The underlying point here is that any value stored in a dataSet, datatable, datarow are just objects. You must cast them to the result you are looking for. In your example:

lnAmt = (int)rdr["maxordamt"];
lnAmt = Convert.ToInt32(rdr["maxordamt"]);

would both work. You don't need the overhead of converting to string then converting to int.

>>>C# doesn't like lnAmt = rdr["maxordamt"];.
>

>Hi Michel.
>I just panic.
>If I do this...
>
> strQuery = rdr["maxordamt"].ToString();
> namt = int.Parse(strQuery);
>
>It seems to work.
>I guess I just need to be more creative and put more thought into what I'm doing with C#.
>
>
>lnAmt = rdr["maxordamt"] gave me "Cannot implicitly convert object into string..." error message.
>
>Thanks
>
>>
>>What do you mean by "C# doesn't like"? Are you obtaining an error message? If yes, this is necessary for one to provide support. It would also help to see your SQL command. We cannot see it in here as it hasn't been provided in the code sample.
>>
>>>And I can't do lnAmt = rdr["maxordamt"].ToString();.
>>>How do I save maxordamt, which is a numeric (99999.99) into lnAmt variable so I can insert it into orderamt field in MyTarget table which is also numeric?
>>
>>Once the first situation resolved, that command should work. Note that you do not have to convert to string.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform