how to update sql db table from asp.net
-
Can anyone tell me how to take user input from an application and insert that into SQL database table. I am very new to asp.net. And had tried the below code: insert_cmd = string.Format("Insert into CreateTask(@Title,@AssignedTo,@AssignedDate,@EstimatedEfforts,@Priority)"); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. mycmd.Parameters.Add(new SqlParameter("@Title", SqlDbType.NText, 11)); mycmd.Parameters["@Title"].Value = inpTitle; The new parameters are created for the other fileds same as above. When I run this program the error displayed as: "The name 'inpTitle' does not exist in the current context"
Sailaja
-
Can anyone tell me how to take user input from an application and insert that into SQL database table. I am very new to asp.net. And had tried the below code: insert_cmd = string.Format("Insert into CreateTask(@Title,@AssignedTo,@AssignedDate,@EstimatedEfforts,@Priority)"); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. mycmd.Parameters.Add(new SqlParameter("@Title", SqlDbType.NText, 11)); mycmd.Parameters["@Title"].Value = inpTitle; The new parameters are created for the other fileds same as above. When I run this program the error displayed as: "The name 'inpTitle' does not exist in the current context"
Sailaja
To Insert into SQL database try following steps 1 - Include System.Data.SqlClient 2 - Intialize SQLConnection class 3 - Set connection string 4 - Create SQLCommand class. You type queries in this class object 5 - Call SQLCommand
ExecuteNonQuery()
method. Go through some books that explains ADO.NET in detail before you start.
-
To Insert into SQL database try following steps 1 - Include System.Data.SqlClient 2 - Intialize SQLConnection class 3 - Set connection string 4 - Create SQLCommand class. You type queries in this class object 5 - Call SQLCommand
ExecuteNonQuery()
method. Go through some books that explains ADO.NET in detail before you start.
hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(
Sailaja
-
hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(
Sailaja
potlakayala wrote:
plz send me some refernces if any for learning this..
-
hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(
Sailaja
-
Your SQL insert statement does not appear to be correct. INSERT INTO table(fieldname1,fieldname2,etc) VALUES(value1,value2,etc) WHERE fieldnameX = valueX;
I don't want to give any fixed value in the insert command. I want the command to take the user input values entered from the UI and store those values in the database.
Sailaja