vb asp.net form for adding records to Access Database

S

slinky

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.
 
S

slinky

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top