post from text box to SQL insert


I'm trying to update a single field of a record and i want to do it using a standard multi line text box but I'm not sure how to write the c# command to process the sql update.  I would also like the entry to be added into the database with line breaks.


Thanks for your help 

9/21/2006 3:28:02 AM 29906 articles. 0 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 55

There is nothing to ask...... you can do it using the same way u r updating the others..... you do not need any c# command..... its the query on which all this depends...

you can use query... :     update <table name> set <feild name>= textbox1.text where <condition>.....

 and about multi lines..... you do not need to worry about line breaks...... the data would be stored in the database just as the way it is in the multiline textbox..... and would be fetched in the same manner....

and do tell me if its any worthy 4 u or not.

Gurpreet Singh Dhaliwal
9/21/2006 5:51:51 AM

Ok - In theroy I get what your saying but then I have VisStudio post out the code I need to make the text box and the supporting data source and I get all of this:


        <asp:TextBox ID="txtNotes" runat="server"></asp:TextBox>
        <asp:SqlDataSource ID="sqlUpdateNotes" runat="server" ConnectionString="<%$ ConnectionStrings:dbNetOps %>" DeleteCommand="DELETE FROM [MasterServerlist] WHERE [ID] = ?" InsertCommand="INSERT INTO [MasterServerlist] ([ID], [Notes]) VALUES (?, ?)" ProviderName="<%$ ConnectionStrings:dbNetOps.ProviderName %>" SelectCommand="SELECT [ID], [Notes] FROM [MasterServerlist] WHERE ([ID] = ?)" UpdateCommand="UPDATE [MasterServerlist] SET [Notes] = ? WHERE [ID] = ?">
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Notes" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:ControlParameter ControlID="gvServers" Name="ID" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Notes" Type="String" />


What I'm trying to do is :

1: display the contents of the notes field in the text box where the record matches the record selected in a gridview element

2: have the onchange event of the notes field then post back an update to the database and redisplay the new notes in the text field


I'm very new to ASP and appriciate your help.


Thank you



9/21/2006 11:03:05 PM

I cannot find anything wrong in your code.... could you please describe your problem in details........ or what kind of errors you are receiving(if any)......

And also you wanted to store all the data in the textbox to the database with the line breaks..... you should set the textmode attribute of textbox to multiline....

Gurpreet Singh Dhaliwal
9/22/2006 5:05:50 AM

I am trying to get this code to work for me.

 Could someone explain what the <condition>  means and what goes there.


Also could someone use this syntax into a sample code?

Is this right?

update<tblCourse>set<grade> = textbox1 where <???>

is this syntax correct or are the "<>" not right?


Thank you,

Ty Welcome

9/13/2008 3:05:43 AM

Hello there,

In the SQL command specified above,
with something written in italics, between <> means that the table or column names best suited according to your situation...
Like in your this might be

update tblCourse set grade  = textbox1 where <???>

<???> can ce any condition that matches your update condition

Gurpreet Singh Dhaliwal
10/29/2008 1:57:13 PM

Similar Artilces:

Text boxes and SQL datasource
I am using MS Web Developer 2008 Express with a SQL database attached coding in .NET. I've created text boxes for users to enter information however I am unsure how to code the "Save" button so that upon its click all the data entered into the text boxes will be added to the database. Is there a way to do it through the aspx page or is that coding done on the aspx.vb page? Any guidance would be greatly appreciated.   Thanks, Sheena K.Sheena K. Check out the data access Tutorials. They are really well done and easy to follow. &nb...

Inserting values from a text box into a SQL query
I have a web page that has a text box with a submit button and what I'm trying to do is to have the text that is entered into this box fill in the N value below: use MDR exec [dbo].[getoncall] @subschedule = N'' The two questions I have are: 1. how do I tie the value of the text box to fill in the N value 2. how do I thenn post that result to a web page. Any help would be appreciated. Thank you This is my code for the originating page so far: (as you can see its pretty basic) Type the name of the Schedule yo #form1 { text-align: center...

Simple insert from text box into SQL database
I have a simple text box and I want to insert it's contents via a submit button into a database table.  Thanks AndrewCurrent project: Cycle round the world You have few options here: 1) super easy : drag and drop formview control, change its default mode to INSERT and you will have nice form that will allow you insert info from textboxes 2) drag SqlDatasource to wwebForm > configure it (insert statment) >  double click "submit button" to open code behind set parameter to textbox : sqldatasource1.parammeters("parameter_here").defaultvalue = textbox1.text 'insert data...

Insert SQL on Sql Command
i'm using an sql command for insert query it looks like this cmd=new sqlcommand("insert into tblname values('" & textbox1.text & "')",cn) cmd.executereader the problem is if i type a singlequote or double quote an error is throwing,invalid syntax .... how can i s'rt out it with out using a sql stored procedure thanks in advance PrasantHI think therefore i'mvPras© Hi, try replacing the single quotes present in your input with double single quotes ... example below: string sqlInput = textbox1.text.Replace("'","''...

how to access text box values in sql insert command?
Hi,      I need to insert the textbox values  into the database. Please review the code below and give me the exact syntax to access the textbox values and use them in the sq linsert command. private void Button1_Click(object sender, System.EventArgs e) { string scon,firstname,lastname,empid; firstname=Text1.Text; lastname=Text2.Text; empid=Text3.Text; scon=ConfigurationSettings.AppSettings["connection"]; SqlConnection obcon=new SqlConnection(scon); string sql = string.Format("insert into trial_emp (firstname, lastname, emp_id) values( ) "); SqlCommand c...

Insert Records Using from Text box to SQL database
Hi, I am having three text box which accepts user data & insert that in sql database. But I am not able to do this , I think this is the simplest of all . Can somebody plz tell me how this can be done from scratch that is connection string & settings in web.config ? Plz guide using C#ThanksRegards,-Sunny,           Here's a simple example using a SqlDataSource. WEB.CONFIG <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=AMERUS-CW6GLINJ\SQLEXPRESS;Initial Cat...

How to insert a record in sql express data base from text box by a button
I am a new 2 developer please can any body tell me how can is insert new record in sql express database from a text box, and using a simple button. Quick and Simple example: <%@ Page Language="VB" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %> <script runat="server">     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)        Try            Dim myConnection As New SqlConn...

how do i insert data into sql server using data from textboxes and sql connection and sql command
anyone can give me a simple explaination and code.. Thanx in advance Take a look @ Sample Code: How to add...Sushila Bowalekar PatelVisual ASP/ASP.NET MVP There are a lot of tutorials out there, but I know they can be a bit confusing as they all approach things slightly differently. Basically a nice simple version would go like this:' *** First set up your connectionDim conConnection As New SqlConnection("server=servername;database=yourdatabase;uid=yourname;pwd=yourpassword;")' *** This line takes care of your sommand text and command connection in one ...

SQL insert from text box works, but can't display data after
Ok so I got my insert statement to work properly from multiple text boxes and a button control.  What I'm looking to do is once the customer hits the button and it creates the new row in the table I want to then display the recently created record.  Currently when I hit submit it creates the record, but the screen then goes back to default.  I can then go to another page that I created to browse the records and it sees that the record was created properly.  I would like for the insert to complete and then for the recently created record to be displayed either with a p...

How to insert numbers from a text box to a Sql database table column’s type numeric?
Hi, I am getting an error when I try to insert a number typed in a text box control into a Sql database table column’s type numeric(6,2). For example: If I type 35,22 into the text box, or 35, and then I submit the form to insert the data into database, I get the follow error: System.FormatException: Input string was not in a correct format. Line 428: CmdInsert.Parameters.Add(New SqlParameter("@Measure", SqlDbType.decimal, "Measure")) A piece of the SP inside Sql server: USE market26 GO ALTER PROC new_offer @Offer_id bigint, @Measure numeric...

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

when to use sql update and sql insert
I have a page where the user can update stock records. it has 5 x 5 text boxes. If the user has already entered stock before that stock will show up and they can change it and clicking the button it will update, however if they have just entered new data i would assume they would need to insert it, so how do i go about doing this? do i need to use both insert and update in the same sql string?Jeremy HusonSenior Network EngineerCarden Computers - PC Repair Brighton Hi,   Generally in such a situation we normally differentiate  the records for updation and inserion through the...

I am attempting to post to another page and pass a form text box to a sql data source as a query variable.
Hello. I used to use dreamweaver and vbscript to post a form to another page and then use Request.Form to get the variable from the form and put it in a query. I have been trying to do the same in I have managed to get it to work with postback. However when I change the property of the submit button to post the page to another page and specify on the target page a form variable in a data source it does not work. It just reverts to the default. Is there something else I need to set up for it to pick up the form variable from the source page? All help would be gratefully appreciated....

Variable Insert to SQL server insert satement setting values for the @variable INSIDE sql
ok, I am on Day 2 of being brain dead.I have a database with a table with 2 varchar(25) columns I have a btton click event that gets the value of the userName,  and a text box.I NEED to insert a new row in a sql database, with the 2 variables.Ive used a sqldatasource object, and tried to midify the insert parameters, tried to set it at the button click event, and NOTHING is working. Anyone have a good source for sql 101/ASP.Net/Braindead where I can find this out, or better yet, give me an example.  this is what I got <%@ Page Language="C#" %><!DOCTYPE html ...

Web resources about - post from text box to SQL insert -

Package insert - Wikipedia, the free encyclopedia
In the United States, the Food and Drug Administration (FDA) determines the requirements for patient package inserts. Other national or international ...

Inserts Wallpapers & Photos on the App Store on iTunes
Get Inserts Wallpapers & Photos on the App Store. See screenshots and ratings, and read customer reviews.

Please Insert Coin - Flickr - Photo Sharing!
Explore arsheffield's photos on Flickr. arsheffield has uploaded 6582 photos to Flickr.

Ice Cube-I'm Scared (Insert)-The Predator - YouTube
Artist:Ice Cube Title:I'm Scared (Insert) Album:The Predator Year:1992

Google halts public map edits after prankster inserts image of Android robot urinating on Apple logo
Google sidelines crowd-sourced map-making tool to prevent embarrassing edits.

Dear [insert name], Qantas takes your complaint very seriously, honest
What's more annoying than being delayed nine hours on a long-haul flight between Sydney and Los Angeles, while stuck in a seat with a broken ...

Skype to insert advertising into calls
Skype to insert advertising into calls

ISIS inserts disturbing images into N.L. vote Twitter chatter
Note: The CBC does not necessarily endorse any of the views posted. By submitting your comments, you acknowledge that CBC has the right to reproduce, ...

Samsung Galaxy Note 5 now ships with warning not to insert S-Pen the wrong way
... YouTube unboxing video reveals that Samsung has begun shipping its Galaxy Note 5 handsets with a warning label, telling users not to insert ...

Updates to Google Docs & Slides let you insert & quickly edit images on iOS
Google is today rolling out updates to its Google Docs and Slides mobile apps bringing the ability to insert images directly from the app on ...

Resources last updated: 1/16/2016 2:27:32 AM