C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




hello tell me what is the mistake here


Posted Date: 20 Aug 2008      Total Responses: 4

Posted By: G.Srinuvasula Reddy       Member Level: Silver     Points: 1


Hello friends

here i paste my C# code .when i run this code i had a error

Error is sno can not belongs to m_company.

plz tell me what is the mistake.

my code is
SqlDataAdapter da;
DataSet ds;
int i;
Sql = "select max(Sno)+1 from M_company";
da = new SqlDataAdapter(Sql, Con);
ds = new DataSet();
da.Fill(ds, "m_company");
i = (int)ds.Tables["m_company"].Rows[0]["sno"];------------->this line shows error

regards
gsr




Responses

Author: D.Jeya kumar(JK)    20 Aug 2008Member Level: DiamondRating:     Points: 3
hi,


Can you please modify the below line

Sql = "select max(Sno)+1 from M_company";

to

Sql = "select max(Sno)+1 as sno from M_company";

Let me know if you have any issues

Regards
JK



Author: ANIL PANDEY    20 Aug 2008Member Level: DiamondRating:     Points: 2
Hi,

What is the Error u r getting as ur code seems to be OK.

if u specify the error i can try


Thanks
Anil


Author: Arun Rajan    20 Aug 2008Member Level: GoldRating:     Points: 2
Jeya kumar's solution is right! But you may optimize your code by implementing ExecuteScalar instead of the DataSet object.


Author: Misha    20 Aug 2008Member Level: BronzeRating:     Points: 3

Hi,

Plz change ur sql command to like this
Sql = "select max(Sno)+1 as Sno from M_company";

and use the same code as above, only change the command, select the max + 1 as Sno.

Hope this may help u.
Regards,
Misha



Post Reply
You must Sign In to post a response.
Next : How To Add Images to a Image control
Previous : Preserving Value of textBox
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use