RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2624 | Replies: 5 | Solved
Reply
Join Date: Mar 2007
Posts: 14
Reputation: someoneelse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
someoneelse someoneelse is offline Offline
Newbie Poster

need help with sql database in asp.net using VB

  #1  
Mar 19th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation: f1 fan is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

  #2  
Mar 23rd, 2007
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
Reply With Quote  
Join Date: Jan 2007
Posts: 7
Reputation: bubbliciousbar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
bubbliciousbar bubbliciousbar is offline Offline
Newbie Poster

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

  #3  
Mar 23rd, 2007
i find http://www.w3schools.com/ good when ever i get stuck. hope it helps!
Reply With Quote  
Join Date: Mar 2007
Posts: 14
Reputation: someoneelse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
someoneelse someoneelse is offline Offline
Newbie Poster

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

  #4  
Mar 23rd, 2007
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
Reply With Quote  
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation: f1 fan is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

  #5  
Mar 23rd, 2007
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: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>
Reply With Quote  
Join Date: Apr 2006
Posts: 87
Reputation: blacklocist is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
blacklocist blacklocist is offline Offline
Junior Poster in Training

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

  #6  
Mar 25th, 2007
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 4:33 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC