944,183 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 3967
  • ASP.NET RSS
Mar 19th, 2007
0

need help with sql database in asp.net using VB

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
someoneelse is offline Offline
14 posts
since Mar 2007
Mar 23rd, 2007
0

Re: need help with sql database in asp.net using VB

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
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 23rd, 2007
0

Re: need help with sql database in asp.net using VB

i find http://www.w3schools.com/ good when ever i get stuck. hope it helps!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
bubbliciousbar is offline Offline
7 posts
since Jan 2007
Mar 23rd, 2007
0

Re: need help with sql database in asp.net using VB

I am not using VS2005. I am basically using Notepad, well, ok, an HTML editor....

so, I appreciate the help f1 fan, but it really didn't do too much for me i just need a straight up example of asp.net form and inserting the results into a db, preferabbly SQL
Reputation Points: 10
Solved Threads: 0
Newbie Poster
someoneelse is offline Offline
14 posts
since Mar 2007
Mar 23rd, 2007
0

Re: need help with sql database in asp.net using VB

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
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
  2. AutoGenerateColumns="False" DataKeyNames="aID" DataSourceID="SqlDataSource1" Caption="Collections" Width="300px">
  3. <Columns>
  4. <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
  5. <asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
  6. <asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
  7. </Columns>
  8. </asp:GridView><br /><br />
  9. <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
  10. DataKeyNames="aID" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px"
  11. Width="300px" Caption="Add New Collection">
  12. <Fields>
  13. <asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
  14. <asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
  15. <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
  16. </Fields>
  17. </asp:DetailsView>
  18. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
  19. ConnectionString="<%$ ConnectionStrings:CHComConnectionString %>" DeleteCommand="DELETE FROM [Collections] WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName"
  20. InsertCommand="INSERT INTO [Collections] ([aID], [CollectionName]) VALUES (newid(), @CollectionName)"
  21. OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [aID], [CollectionName] FROM [Collections] order by [CollectionName]"
  22. UpdateCommand="UPDATE [Collections] SET [CollectionName] = @CollectionName WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName">
  23. <DeleteParameters>
  24. <asp:Parameter Name="original_aID" Type="Object" />
  25. <asp:Parameter Name="original_CollectionName" Type="String" />
  26. </DeleteParameters>
  27. <UpdateParameters>
  28. <asp:Parameter Name="CollectionName" Type="String" />
  29. <asp:Parameter Name="original_aID" Type="Object" />
  30. <asp:Parameter Name="original_CollectionName" Type="String" />
  31. </UpdateParameters>
  32. <InsertParameters>
  33. <asp:Parameter Name="CollectionName" Type="String" />
  34. </InsertParameters>
  35. </asp:SqlDataSource>
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 25th, 2007
0

Re: need help with sql database in asp.net using VB

I would serriously look into the webdevolper express. I think you will fall in love with it plus it just makes everything much more organized. Just my two cents
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
blacklocist is offline Offline
87 posts
since Apr 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Information Tags
Next Thread in ASP.NET Forum Timeline: Passing An Connecting String





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC