473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

vb asp.net form for adding records to Access Database

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.

Aug 6 '07 #1
1 1418
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 <campbellbrian2...@yahoo.comwrote:
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.

Aug 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
1
by: John Hargrove | last post by:
I am building a database to manage test samples in an environmental laboratory. I am learning Access as I go and don't know much about the programming aspects. I hope to make the application...
6
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: Wayne Aprato | last post by:
I have just sent a demo database to a client. They are using a new PC with a fresh install of Office XP. One of the main forms of the database is not showing any of its textboxes - just a blank...
1
by: RC | last post by:
I have an Access 2002 database with many tables and forms (but just to keep things simple, let's say the DB has one Table "Table1" and one Form "Form1"). I have managed to cobble together so much...
4
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within the form is a subform that is also, through a Q,...
8
by: fonzie | last post by:
Is it possible to have a data entry form where the information is stored in several different tables (5 or 6)? I have an inventory database where Table1 stores all of the data common to all...
17
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.