Showing posts with label record. Show all posts
Showing posts with label record. Show all posts

Tuesday, March 20, 2012

post from text box to SQL insert

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...

Friday, March 9, 2012

Possible to Loop thru dataset using Custom Code?

Is there a way to pass a record set into a function of custom code?
If so?
What datatype should I use?
I have been told its impossible to loop thru the dataset...
Can you get the INDEX of the First row and the INDEX of the last row as
a parameter into a custom function?
regards,
Stas K.Mr. Sorcerdon,
Your best bet would be to implement a Custom Data Processing extension.
This will give you access to dataset being consumed by the report.
Specifically, the IDataReader has a Read method which walks the
dataset.
Andy Potter|||I dont you to go too deep into it, but basically make an Object as a
parameter and then read that object using this extension?
Is there a place where I can get code for this Custom Data Proccessing
extension?|||It is a class library that sits between your data source and your
report's dataset. It implements interfaces from MSRS.
Here's the MSDN article about a Custom Data Processing Extension.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_prog_extend_dataproc_5c2q.asp
There are several good samples out there. Teo Lachev has a good one
that a google search will return.
Andy Potter

Wednesday, March 7, 2012

Possible to avoid the FILLING of GAP (created by deleting a record) in the Identity Column

Hi all,

(I am using SQL Server 2005)

I have created a new 'CUSTOMERS' table and created a colum 'CustomerID' as an Identity column.

Now, a problem I find is that when I delete a particular record, its Identity value is used automatically for the New record I insert later!

I do not want to re-use the already used Identity value.

I just want to have the last CustomerID to be higher that all the previous ones.

Is there any way to do this?

Thanking you in advance,

Tomy

How are you deleting this record? If you follow this example through, you'll see that new records will get a new ID:

-- CREATE THE TABLECREATE TABLE CUSTOMER (idint IDENTITY(1,1),name varchar(50))-- INSERT TWO TEST RECORDSINSERT CUSTOMERVALUES ('Mark')INSERT CUSTOMERVALUES ('Fred')-- SHOW THE TWO TEST RECORDSSELECT id,name FROM CUSTOMER-- DELETE THE SECOND RECORDDELETE CUSTOMERWHERE id = 2-- INSERT A NEW RECORDINSERT CUSTOMERVALUES ('Joe')-- SHOW ALL THE RECORDS (THE NEW CUSTOMER WILL HAVE A NEW ID)SELECT id,name FROM CUSTOMER-- DROP THE TABLEDROP TABLE CUSTOMER
|||

Hi,

I inserted the records through program, and later, I deleted, the records manually using Visual Development Studio Manager. Later, when I inserted new records programatically, I found that even the deleted IDs were used.

Thanks

Tomy