•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 373,502 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,853 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2240 | Replies: 5 | Solved
![]() |
•
•
Join Date: Mar 2007
Posts: 14
Reputation:
Rep Power: 2
Solved Threads: 0
I am new to ASP.net as of today 
I have jumped many hunrdles alreday, writing/deleting text files, connecting to a db, sendiong emails, yeah me.
I am looking for 1 concise example to show how i can take the contents of a form and insert them into a datbase. i am having the worst time trying to find a tutorial or example that explains this is a way that makes sense and that also works.
please, can someone help me?
i just need a straight up form that has like name, last name, phjone and emial, that can store it into a database - right now im using a MYSQL db, but if i can see it in access, i should be able to convert.
thanks!
~ Andrea

I have jumped many hunrdles alreday, writing/deleting text files, connecting to a db, sendiong emails, yeah me.
I am looking for 1 concise example to show how i can take the contents of a form and insert them into a datbase. i am having the worst time trying to find a tutorial or example that explains this is a way that makes sense and that also works.
please, can someone help me?
i just need a straight up form that has like name, last name, phjone and emial, that can store it into a database - right now im using a MYSQL db, but if i can see it in access, i should be able to convert.
thanks!
~ Andrea
•
•
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation:
Rep Power: 3
Solved Threads: 10
use the formview control and bind it to a datasource control which is configured to access your database.
If you use VS2005 they are there and very simple to setup (follow the wizards). Drop a form view onto your page, where it says datasource use the drop down to make a new one and follow the wizard to configure the datasource to do selects, updates, inserts and deletes to your database.
When it is all done and working properly you will be able to see the code it created and understand what it did and then you can roll your own at any time.
The datasource is a powerful tool, especially the object datasource if you are using multi tier applications
If you use VS2005 they are there and very simple to setup (follow the wizards). Drop a form view onto your page, where it says datasource use the drop down to make a new one and follow the wizard to configure the datasource to do selects, updates, inserts and deletes to your database.
When it is all done and working properly you will be able to see the code it created and understand what it did and then you can roll your own at any time.
The datasource is a powerful tool, especially the object datasource if you are using multi tier applications
•
•
Join Date: Jan 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 1
i find http://www.w3schools.com/ good when ever i get stuck. hope it helps!
•
•
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation:
Rep Power: 3
Solved Threads: 10
OK
You can get webdeveloper express which is free and makes it a lot easier.
the code below has a grid view which lets me list, edit and delete items in the grid (it could select too but i have no need of that in this example).
grid views dont allow news rows so i use a details view (below it) which is in default mode of insert.
Both are bound to the sqldatasource which you see below them. In my case i have the connection string elsewhere in my app which it knows to go find by the <%$ ... %> tags. You can use stored procs etc but i included this code for you to see
Hope it helps you
You can get webdeveloper express which is free and makes it a lot easier.
the code below has a grid view which lets me list, edit and delete items in the grid (it could select too but i have no need of that in this example).
grid views dont allow news rows so i use a details view (below it) which is in default mode of insert.
Both are bound to the sqldatasource which you see below them. In my case i have the connection string elsewhere in my app which it knows to go find by the <%$ ... %> tags. You can use stored procs etc but i included this code for you to see
Hope it helps you
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="aID" DataSourceID="SqlDataSource1" Caption="Collections" Width="300px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
<asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
</Columns>
</asp:GridView><br /><br />
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="aID" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px"
Width="300px" Caption="Add New Collection">
<Fields>
<asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
<asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:CHComConnectionString %>" DeleteCommand="DELETE FROM [Collections] WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName"
InsertCommand="INSERT INTO [Collections] ([aID], [CollectionName]) VALUES (newid(), @CollectionName)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [aID], [CollectionName] FROM [Collections] order by [CollectionName]"
UpdateCommand="UPDATE [Collections] SET [CollectionName] = @CollectionName WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName">
<DeleteParameters>
<asp:Parameter Name="original_aID" Type="Object" />
<asp:Parameter Name="original_CollectionName" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CollectionName" Type="String" />
<asp:Parameter Name="original_aID" Type="Object" />
<asp:Parameter Name="original_CollectionName" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CollectionName" Type="String" />
</InsertParameters>
</asp:SqlDataSource>![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
.net .net framework 3.0 access ajax asp avatar backup breach code combo custom daniweb data data protection database design developer development dom dropdownlist feed government hacker ibm medicine microsoft module msdn net news normalization office reader reuse security server skin software sql survey theme vista weather web windows workflow xml xoap
- How to connect MSAccess database in ASP.NET (C#)
- add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0 (ASP.NET)
- SQL Server, Images and DataGrid in ASP.NET (ASP.NET)
- How to connect sql database in asp.net using VB? (ASP.NET)
- Clustered Cache in ASP.NET (ASP.NET)
- plz help me to connect more than one table in the ms access database to the asp.net (ASP.NET)
- tool for converting java/sql codes to asp.net/sqol2000 (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: Information Tags
- Next Thread: add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0


Linear Mode