Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > vb asp.net form for adding records to Access Database

Reply
Thread Tools

vb asp.net form for adding records to Access Database

 
 
slinky
Guest
Posts: n/a
 
      08-06-2007
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.

 
Reply With Quote
 
 
 
 
slinky
Guest
Posts: n/a
 
      08-06-2007
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 <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Submit Form Elements to Insert Multiple Records into a Database Sans Spam ASP General 8 05-24-2004 09:16 PM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM
match muliple header records to associated detail records Luke Airig XML 0 12-31-2003 12:06 AM



Advertisments