Hello,
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
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.
|||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] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="gvServers" Name="ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Notes" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
------------------
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
|||
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...
No comments:
Post a Comment