Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello friends,
i have a problem in coding of C# with SQL server..problem is,there is table in sql with one column of 'int' datatype...and when i try to insert values in that table then there comes an error..
eg->
C#
int amt=Conevert.ToInt32(textbox1.text);

string sql="insert into Table values(amt)";


the error is pointing at variable "amt"...plz help me...how to insert a
C#
int
number through coding and variable....
Posted

mySqlCommand.Parameters.AddWithValue("@amt", amt)
 
Share this answer
 
Try this:
C#
string sql="insert into Table (amt) values(@amt)";
 
Share this answer
 
Comments
[no name] 30-Mar-12 10:16am    
no...there are other columns also..not a single..
Prasad_Kulkarni 30-Mar-12 10:35am    
then add all columns.. else post complete columns..
Why don't you do this just as simple as


C#
int amt=Conevert.ToInt32(textbox1.text);

string sql="insert into Table values("+ amt +")";
 
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