vb asp.net form for adding records to Access Database

Discussion in 'ASP .Net' started by slinky, Aug 6, 2007.

  1. slinky

    slinky Guest

    On My Webserver I have an Access Database called "Warehouse.mdb"

    I have a webform that has:

    6 Textboxes named: txtAsset_Number.Text, txtDescription.Text,
    txtSerial_Number.Text, txtMfg.Text, txtRDCnumber.Text,
    txtAssetType.Text

    1 Button named btnAdd

    I dragged the Table called Assets onto my design surface (I'm using
    Visual Web Developer Express. On another form I was able to drag the
    table over and see the data in a gridview - but I want to add data to
    the table - but in the fashion of textboxes and a submit button) to
    get my datasource available.

    What I need to do is take the values in the textboxes and update the
    database's table called "Assets".

    What I have so far is just this code:

    Imports System.Data.OleDb
    Partial Class Default5
    Inherits System.Web.UI.Page
    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles btnAdd.Click
    rowNew.Asset_Number = txtAsset_Number.Text
    rowNew.Description = txtDescription.Text
    rowNew.Serial_Number = txtSerial_Number.Text
    rowNew.Mfg = txtMfg.Text
    rowNew.RDCnumber = txtRDCnumber.Text
    rowNew.AssetType = txtAssetType.Text
    End Sub
    End Class

    So what I have above may not be the best code... for one thing I don't
    know what to Dim the rowNew. Plus I need help knowing where to place
    the code for the Update, etc.

    I've looked in 2 Textbooks that have two different solutions. But I'm
    stuck on how to make this work.
    Any help would be appreciated. I don't want to have an Editable
    Gridview to enter data... I'd like to learn how to do this in a
    structured way.
     
    slinky, Aug 6, 2007
    #1
    1. Advertising

  2. slinky

    slinky Guest

    Would something like this work?

    Imports Microsoft.VisualBasic
    Public Class Class2
    Inherits System.Web.UI.Page
    Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    Dim DataSet As AccessDataSource
    If Not IsPostBack Then
    Using ds As New DataSet()
    txtAsset_Number.Text.DataBind()
    txtDescription.Text.DataBind()
    txtSerial_Number.Text.DataBind()
    txtMfg.Text.DataBind()
    txtRDCnumber.Text.DataBind()
    txtAssetType.Text.DataBind()
    End Using
    End If
    End Sub
    Private Sub btnAdd_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnAdd.Click
    Using ds As New DataSet()
    Dim dr As DataRow = ds.Tables(0).NewRow()
    dr("Asset_Number") = txtAsset_Number.Text
    dr("txtDescription.Text") = txtDescription.Text
    dr("txtDescription.Text") = txtSerial_Number.Text
    dr("txtMfg.Text") = txtMfg.Text
    dr("txtRDCnumber.Text") = txtRDCnumber.Text
    dr("txtAssetType.Text ") = txtAssetType.Text
    ds.Tables(0).Rows.Add(dr)
    End Using
    End Sub
    End Class

    On Aug 6, 3:04 pm, slinky <> wrote:
    > On My Webserver I have an Access Database called "Warehouse.mdb"
    >
    > I have a webform that has:
    >
    > 6 Textboxes named: txtAsset_Number.Text, txtDescription.Text,
    > txtSerial_Number.Text, txtMfg.Text, txtRDCnumber.Text,
    > txtAssetType.Text
    >
    > 1 Button named btnAdd
    >
    > I dragged the Table called Assets onto my design surface (I'm using
    > Visual Web Developer Express. On another form I was able to drag the
    > table over and see the data in a gridview - but I want to add data to
    > the table - but in the fashion of textboxes and a submit button) to
    > get my datasource available.
    >
    > What I need to do is take the values in the textboxes and update the
    > database's table called "Assets".
    >
    > What I have so far is just this code:
    >
    > Imports System.Data.OleDb
    > Partial Class Default5
    > Inherits System.Web.UI.Page
    > Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnAdd.Click
    > rowNew.Asset_Number = txtAsset_Number.Text
    > rowNew.Description = txtDescription.Text
    > rowNew.Serial_Number = txtSerial_Number.Text
    > rowNew.Mfg = txtMfg.Text
    > rowNew.RDCnumber = txtRDCnumber.Text
    > rowNew.AssetType = txtAssetType.Text
    > End Sub
    > End Class
    >
    > So what I have above may not be the best code... for one thing I don't
    > know what to Dim the rowNew. Plus I need help knowing where to place
    > the code for the Update, etc.
    >
    > I've looked in 2 Textbooks that have two different solutions. But I'm
    > stuck on how to make this work.
    > Any help would be appreciated. I don't want to have an Editable
    > Gridview to enter data... I'd like to learn how to do this in a
    > structured way.
     
    slinky, Aug 6, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFuaXNoIFNhd2ppYW5p?=

    Adding records to MS Access 97 Tables using ASP.net

    =?Utf-8?B?TWFuaXNoIFNhd2ppYW5p?=, Feb 4, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    428
    =?Utf-8?B?TWFuaXNoIFNhd2ppYW5p?=
    Feb 4, 2005
  2. Luke Airig
    Replies:
    0
    Views:
    795
    Luke Airig
    Dec 31, 2003
  3. MA P
    Replies:
    0
    Views:
    455
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    466
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    666
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page