473,385 Members | 1,449 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,385 software developers and data experts.

problem with .aspx code

I have a form that has 6 Textboxes to enter data and a button to
write
the data to my Access database which resides on the same server as my
website. It's an .aspx page. I find no errors except the 3rd and 4th
lines throw errors. I got this basic example from a book (Written by
Mike Gunderloy for
MS Exam 70-305 page 481) which said to, while in design view, double
click the button to open the form's
module and place the code below. Just a thought, but the book didn't
mention this
but how does the code know that clicking the Submit button should run
the Page_Load?
I'm using Visual Web Developer 2005
Express. Any clues? Thanks!!!

Line numbers for reference only - here's my errors:
Line 3: Private Sub Page_Load(ByVal sender As System.Object, _
Statement is not valid in a namespace.
Line 4: ByVal e As System.EventArgs) Handles MyBase.Load
Statement is not valid in a namespace.

Imports System.Data
Imports System.Data.OleDb
3) Private Sub Page_Load(ByVal sender As System.Object, _
4) ByVal e As System.EventArgs) Handles MyBase.Load
If IsPostBack Then
Dim cnn As OleDbConnection("data Source=(local);" & _
"Initial Catalog=Lowes;" & _
"Integrated Security=SSPI")
Dim cnn As OleDbConnection
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = _
New OleDbDataAdapter()
Dim cmdSelect As OleDbCommand = _
Cnn.CreateCommand()
cmdSelect.CommandType = CommandType.Text
cmdSelect.CommandText = _
"SELECT Asset_Number, Description, Serial_Number, Mfg, RDCnumber,
AssetType FROM Assets"
Dim cmdInsert As OleDbCommand = _
Cnn.CreateCommand()
cmdInsert.CommandType = CommandType.Text
cmdInsert.CommandText = _
"INSERT INTO Customers " & _
"(Asset_Number, Description, Serial_Number, Mfg, RDCnumber,
AssetType) "
"VALUES(@Asset_Number, @Description, @Serial_Number, @Mfg,
@RDCnumber,
@AssetType)"
cmdInsert.Parameters.Add(@Asset_Number" , OleDbType. 10,"
Asset_Number")
cmdInsert.Parameters.Add(@Description" , OleDbType.VarChar, 40,"
Description")
cmdInsert.Parameters.Add(@Serial_Number" , OleDbType.VarChar, 30,"
Serial_Number")
cmdInsert.Parameters.Add(@Mfg" , _OleDbType.VarChar, _30," Mfg")
cmdInsert.Parameters.Add(@RDCnumber" , OleDbType.VarChar, 30,"
RDCnumber")
cmdInsert.Parameters.Add(@AssetType" , OleDbType.VarChar, 30,"
AssetType")
cmdInsert.Parameters(@Asset_Number"). _
SourceVersion = _
DataRowVersion.Original
da.SelectCommand = cmdSelect
da.InsertCommand = cmdInsert
da.Fill(ds, "Assets")
Dim dr As DataRow = ds.Tables( _
"Assets").NewRow()
dr(0) = txtAsset_Number.Text
dr(1) = txtDescription.Text
dr(2) = txtSerial_Number.Text
dr(3) = txtMfg.Text
dr(4) = txtRDCnumber.Text
dr(5) = txtAssetType.Text
Ds.Tables("Assets".Rows.Add.(dr)
da.Update(ds, "Assets")
End If
End Sub

Aug 3 '07 #1
3 1510
On Aug 3, 9:45 pm, slinky <campbellbrian2...@yahoo.comwrote:
I have a form that has 6 Textboxes to enter data and a button to
write
the data to my Access database which resides on the same server as my
website. It's an .aspx page. I find no errors except the 3rd and 4th
lines throw errors. I got this basic example from a book (Written by
Mike Gunderloy for
MS Exam 70-305 page 481) which said to, while in design view, double
click the button to open the form's
module and place the code below. Just a thought, but the book didn't
mention this
but how does the code know that clicking the Submit button should run
the Page_Load?
I'm using Visual Web Developer 2005
Express. Any clues? Thanks!!!

Line numbers for reference only - here's my errors:
Line 3: Private Sub Page_Load(ByVal sender As System.Object, _
Statement is not valid in a namespace.
Line 4: ByVal e As System.EventArgs) Handles MyBase.Load
Statement is not valid in a namespace.

Imports System.Data
Imports System.Data.OleDb
3) Private Sub Page_Load(ByVal sender As System.Object, _
4) ByVal e As System.EventArgs) Handles MyBase.Load
you should define the class in *.aspx.vb file

Imports System.Data
Imports System.Data.OleDb

Public Class MyFirstPageName Inherits System.Web.UI.Page

.......

End Class

A class name (MyFirstPageName) should be the same as in your *.aspx
file

<%@ Page Inherits="MyFirstPageName" ...

Aug 3 '07 #2
OK I did that, now 23 erros popped up. The name of the file below is
Lowes3.aspx.vb
Lines 3, 5, 6, 7, 25-33, 40-46 (e.g.

Imports System.Data
Imports System.Data.OleDb
Public Class Lowes3.aspx Inherits System.Web.UI.Page <End of
statement expected
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load <event
'Load' cannot be found
If IsPostBack Then
Dim cnn As OleDbConnection("data Source=(local);" & _ <array
bounds cannot appear in type specifiers
"Initial Catalog=Lowes;" & _
"Integrated Security=SSPI")
Dim cnn As OleDbConnection
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = _
New OleDbDataAdapter()
Dim cmdSelect As OleDbCommand = _
cnn.CreateCommand()
cmdSelect.CommandType = CommandType.Text
cmdSelect.CommandText = _
"SELECT Asset_Number, Description, Serial_Number, Mfg, RDCnumber,
AssetType FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateCommand()
cmdInsert.CommandType = CommandType.Text
cmdInsert.CommandText = _
"INSERT INTO Customers " & _
"(Asset_Number, Description, Serial_Number, Mfg,
RDCnumber, AssetType) "
"VALUES(@Asset_Number, @Description, @Serial_Number, @Mfg, @RDCnumber,
@AssetType)" <sysntaz error
cmdInsert.Parameters.Add(@Asset_Number" , OleDbType. 10,"
Asset_Number") < '@' not valid
cmdInsert.Parameters.Add(@Description" , OleDbType.VarChar, 40,"
Description") < '@' not valid
cmdInsert.Parameters.Add(@Serial_Number" , OleDbType.VarChar, 30,"
Serial_Number") < '@' not valid
cmdInsert.Parameters.Add(@Mfg" , _OleDbType.VarChar, _30,"
Mfg") < '@' not valid
cmdInsert.Parameters.Add(@RDCnumber" , OleDbType.VarChar, 30,"
RDCnumber") < '@' not valid
cmdInsert.Parameters.Add(@AssetType" , OleDbType.VarChar, 30,"
AssetType") < '@' not valid
cmdInsert.Parameters(@Asset_Number").
_ < Property access
must assign to the property or use its value
SourceVersion =
_ < Name
'Source Version' is not declared
DataRowVersion.Original
da.SelectCommand = cmdSelect
da.InsertCommand = cmdInsert
da.Fill(ds, "Assets")
Dim dr As DataRow = ds.Tables( _
"Assets").NewRow()
dr(0) =
txtAsset_Number.Text <
txtAsset_Number - not declared
dr(1) =
txtDescription.Text
ditto
dr(2) =
txtSerial_Number.Text
ditto
dr(3) =
txtMfg.Text
ditto
dr(4) =
txtRDCnumber.Text
ditto
dr(5) =
txtAssetType.Text
ditto
Ds.Tables("Assets".Rows.Add.(dr) < Property
access must assign to the property or use its value
da.Update(ds, "Assets")
End If
End Sub
End Class
you should define the class in *.aspx.vb file

Imports System.Data
Imports System.Data.OleDb

Public Class MyFirstPageName Inherits System.Web.UI.Page

......

End Class

A class name (MyFirstPageName) should be the same as in your *.aspx
file

<%@ Page Inherits="MyFirstPageName" ...- Hide quoted text -

- Show quoted text -

Aug 3 '07 #3
On Aug 3, 10:58 pm, slinky <campbellbrian2...@yahoo.comwrote:
OK I did that, now 23 erros popped up. The name of the file below is
Lowes3.aspx.vb
Lines 3, 5, 6, 7, 25-33, 40-46 (e.g.

Imports System.Data
Imports System.Data.OleDb
Public Class Lowes3.aspx Inherits System.Web.UI.Page <End of
statement expected

1) "Inherits System.Web.UI.Page" should start from a new line, like
here

Partial Public Class <classname>
Inherits System.Web.UI.Page

2) Class name should be "Lowes3" (without the ".aspx")

I think the easiest way to learn, is to create a new empty page to see
what IDE added to ASPX and VB files by default. Then you can copy the
code from your book to existing template...

Aug 3 '07 #4

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

Similar topics

1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
6
by: Shamin | last post by:
Hi, Thanks in advance for answering to my Question. I'm stuck with this problem and would really appreciate any help. I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
7
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user...
2
by: MS News Public | last post by:
Hi I have an asp.net 2.0 project and am experiencing a problem. In the project, I am trying to make use of Membership. I have one Role, called "Basic User" and two users - "admin" and...
0
by: james.mcdonagh | last post by:
Hi I am a newbie using nAnt for .net 2.0. As such I have not come across this bug before, and I would be happy of any help that you may be able to provide. In order to help I have included the...
1
by: jamesmcdonagh | last post by:
Hi newbie using nAnt for .net 2.0. I would be happy of any help that you may be able to provide. The weird thing is that VS.net builds without a problem. And the intellisense within the object...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.