Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, in my C# Windows Application Am trying to retrieve a interger value from the database table.

While retrieving ,value is loaded in the dataset. but while assigning that value to some variable like
C#
string s = ds.Tables[0].Rows[0]["Pid"].ToString();

it give an error as "Column 'Pid' does not belong to table Table."

Give me a solution for this.

thank u.
Posted
Updated 7-Sep-12 22:38pm
v2
Comments
Mohamed Mitwalli 8-Sep-12 4:42am    
Make sure this column already exist

"Column 'Pid' does not belong to table Table."
This is because you are trying to access a value from retrieved table row assuming you have a column named 'Pid' in the row, here:
C#
ds.Tables[0].Rows[0]["Pid"].ToString();


Check your query and make sure you have a column named 'Pid' returned.
 
Share this answer
 
Comments
A.Anitha 8-Sep-12 4:52am    
my query is,

alter procedure sp_GetPid_Research
as
select max(Pid) as "Pid" from Tb_ResearchDetails
Sandeep Mewara 8-Sep-12 5:09am    
Ok. What do you see in db when you execute this SP there?
A.Anitha 8-Sep-12 5:44am    
when i execute this query i got the answer as 2.. ie it correctly give the max(Pid) value...
[no name] 8-Sep-12 6:16am    
I think Sandeep Mewara means what's the column name not its value!
Am I right?
Sandeep Mewara 8-Sep-12 8:28am    
Yes.
I think this is because your Table does not contain a column name "Pid" so check your table's columns names.
 
Share this answer
 

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