Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//below is my code
C#
string ID = dset.Tables[0].Rows["ID"].ToString();

//where "ID" IS A COLUMN in registration table data type is int
Posted
Updated 10-Feb-13 20:23pm
v2
Comments
Orcun Iyigun 11-Feb-13 2:23am    
What is the problem?
ntitish 11-Feb-13 2:31am    
sir here i am retrieving data from table where ID data type is in int...
it is showing error like this

The best overloaded method match for 'System.Data.DataRowCollection.this[int]' has some invalid arguments
Argument '1': cannot convert from 'string' to 'int'

Hi,

In your code there is one problem
C#
string ID = dset.Tables[0].Rows["ID"].ToString();

here you haven't mentioned row no., you have only mentioned column name ie. ID
rewrite ur code as below
C#
string ID = dset.Tables[0].Rows[n]["ID"].ToString();

where 'n'= index of row starting from 0.
 
Share this answer
 
v2
Comments
[no name] 11-Feb-13 4:20am    
Good one man. +5
[no name] 11-Feb-13 5:36am    
thnx :)
ntitish 11-Feb-13 7:33am    
thanks sir....i not seen i for got to give row value thanks once again...
I'd use TryParse[^] to make sure the string is really an integer before going ahead with the conversion.
 
Share this answer
 
C#
int id = Convert.ToInt16(ID.ToString());

try this...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900