Click here to Skip to main content
15,909,332 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This is my code :
Cmd = new SqlCommand("UPDATE BillNumber SET BillNumb = BillNumb +1 WHERE Id=1;");
cn.Open();
Cmd.ExecuteNonQuery();
cn.Close();
Posted
Comments
thatraja 21-Nov-13 10:18am    
what's the complete error message?

1 solution

Given the minute amount of information you have provided, I am left only to speculate. But, my guess is that you never initiated a connection for the command. So do one of two things:

1.
Cmd = new SqlCommand("UPDATE BillNumber SET BillNumb = BillNumb + 1 WHERE Id = 1",ConnectionString);

or

2.
Cmd.Connection = "Your connection string";
 
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