DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 03 Aug 2007 12:45:19 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    slinky
          2    Alexey Smirnov
          3    slinky
          4    Alexey Smirnov
          5    slinky


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
Date:Fri, 03 Aug 2007 12:45:19 -0700   Author:  

Re: problem with .aspx code   
On Aug 3, 9:45 pm, slinky  wrote:

> 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" ...
Date:Fri, 03 Aug 2007 13:07:33 -0700   Author:  

Re: problem with .aspx code   
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 -
Date:Fri, 03 Aug 2007 13:58:11 -0700   Author:  

Re: problem with .aspx code   
On Aug 3, 10:58 pm, slinky  wrote:

> 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...
Date:Fri, 03 Aug 2007 15:21:26 -0700   Author:  

Re: problem with .aspx code   
I did take care of this order of code:

 Imports System.Data
 Imports System.Data.OleDb
 Public Class Lowes3
 Inherits System.Web.UI.Page

This got rid of some errors but the follwing remain. I started from
scratch using IDE and in most cases nothing droppeddown that was
usable.     Would the code be a problem since I used SQLserver code
modified for an OleDB??

Here's the error lines that remain:

    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

"VALUES(@Asset_Number, @Description, @Serial_Number, @Mfg,
@RDCnumber,
@AssetType)"   <syntax 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

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

On Aug 3, 6:21 pm, Alexey Smirnov  wrote:

> On Aug 3, 10:58 pm, slinky  wrote:
>
> > 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...
Date:Sun, 05 Aug 2007 21:16:02 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us