| | |
need help with sql database in asp.net using VB
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Mar 2007
Posts: 14
Reputation:
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
Posts: 275
Reputation:
Solved Threads: 11
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:
Solved Threads: 1
i find http://www.w3schools.com/ good when ever i get stuck. hope it helps!
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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.NET Syntax (Toggle Plain Text)
<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>
![]() |
Similar Threads
- 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: Passing An Connecting String
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu mono mssql multistepregistration nameisnotdeclared news novell objects opera problem redirect registration relationaldatabases reportemail rotatepage security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





