Very Simple question

Discussion in 'ASP .Net' started by SL, May 31, 2004.

  1. SL

    SL Guest

    Could someone direct to a simple explanation of how to use MS Visual Studio
    2003 to design .aspx code?
    This code works if pasted into notepad and run as an .aspx file:

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>
    <script language="vb" runat="server">
    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    Dim objConnection As OleDBConnection
    Dim objCommand As OleDBDataAdapter
    Dim strConnect As String
    Dim strCommand As String
    Dim DataSet1 As New DataSet

    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    strConnect += "Persist Security Info=False"

    strCommand = "Select ProductName, UnitPrice FROM products"
    objConnection = New OleDbConnection(strConnect)
    objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    objCommand.Fill(DataSet1, "products")
    DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    DataGrid1.DataBind()
    End Sub
    </script>
    <html>
    <head>
    <title>Data Grid Control Example</title>
    </head>
    <body>
    <asp:DataGrid id="DataGrid1" runat="server" />
    </body>
    </html>

    However, if I open VS, ASP.net web application, go to the sourcecode view,
    paste it in, I get a bunch of errors. It doesn't even recogize " <script
    language="vb" runat="server"> "

    I know there has to be a way.

    Thanks

    Scott
     
    SL, May 31, 2004
    #1
    1. Advertising

  2. SL

    avnrao Guest

    put the script tag inside the head tags.

    Av.
    "SL" <> wrote in message
    news:%...
    > Could someone direct to a simple explanation of how to use MS Visual
    > Studio
    > 2003 to design .aspx code?
    > This code works if pasted into notepad and run as an .aspx file:
    >
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Data.OleDb" %>
    > <script language="vb" runat="server">
    > Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > Dim objConnection As OleDBConnection
    > Dim objCommand As OleDBDataAdapter
    > Dim strConnect As String
    > Dim strCommand As String
    > Dim DataSet1 As New DataSet
    >
    > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    > strConnect += "Persist Security Info=False"
    >
    > strCommand = "Select ProductName, UnitPrice FROM products"
    > objConnection = New OleDbConnection(strConnect)
    > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > objCommand.Fill(DataSet1, "products")
    > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > DataGrid1.DataBind()
    > End Sub
    > </script>
    > <html>
    > <head>
    > <title>Data Grid Control Example</title>
    > </head>
    > <body>
    > <asp:DataGrid id="DataGrid1" runat="server" />
    > </body>
    > </html>
    >
    > However, if I open VS, ASP.net web application, go to the sourcecode view,
    > paste it in, I get a bunch of errors. It doesn't even recogize " <script
    > language="vb" runat="server"> "
    >
    > I know there has to be a way.
    >
    > Thanks
    >
    > Scott
    >
    >
     
    avnrao, May 31, 2004
    #2
    1. Advertising

  3. Hi,

    to use this file in vs.net you just create a new page
    go to the designer in vs.net 2003 select HTML and paste the contents of this
    file to the newly created page.

    thats all.

    i tried this and it for the following code and worked for me.
    if you need you can go a head and put the code in the script tags to the
    respective events in the codebehind file.

    Regards.
    Ashish M Bhonkiya

    "SL" <> wrote in message
    news:%...
    > Could someone direct to a simple explanation of how to use MS Visual

    Studio
    > 2003 to design .aspx code?
    > This code works if pasted into notepad and run as an .aspx file:
    >
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Data.OleDb" %>
    > <script language="vb" runat="server">
    > Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > Dim objConnection As OleDBConnection
    > Dim objCommand As OleDBDataAdapter
    > Dim strConnect As String
    > Dim strCommand As String
    > Dim DataSet1 As New DataSet
    >
    > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    > strConnect += "Persist Security Info=False"
    >
    > strCommand = "Select ProductName, UnitPrice FROM products"
    > objConnection = New OleDbConnection(strConnect)
    > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > objCommand.Fill(DataSet1, "products")
    > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > DataGrid1.DataBind()
    > End Sub
    > </script>
    > <html>
    > <head>
    > <title>Data Grid Control Example</title>
    > </head>
    > <body>
    > <asp:DataGrid id="DataGrid1" runat="server" />
    > </body>
    > </html>
    >
    > However, if I open VS, ASP.net web application, go to the sourcecode view,
    > paste it in, I get a bunch of errors. It doesn't even recogize " <script
    > language="vb" runat="server"> "
    >
    > I know there has to be a way.
    >
    > Thanks
    >
    > Scott
    >
    >
     
    Ashish M Bhonkiya, May 31, 2004
    #3
  4. SL

    Scott Allen Guest

    Scott : Are you pasting the code into the "HTML view" of an ASPX page?
    If you paste this code into a .vb file you'll have errors, it wasn't
    clear what you mean by source code view.


    --
    Scott
    http://www.OdeToCode.com

    On Mon, 31 May 2004 08:25:47 -0400, "SL" <> wrote:

    >Could someone direct to a simple explanation of how to use MS Visual Studio
    >2003 to design .aspx code?
    >This code works if pasted into notepad and run as an .aspx file:
    >
    ><%@ Import Namespace="System.Data" %>
    ><%@ Import Namespace="System.Data.OleDb" %>
    ><script language="vb" runat="server">
    >Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > Dim objConnection As OleDBConnection
    > Dim objCommand As OleDBDataAdapter
    > Dim strConnect As String
    > Dim strCommand As String
    > Dim DataSet1 As New DataSet
    >
    > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    > strConnect += "Persist Security Info=False"
    >
    > strCommand = "Select ProductName, UnitPrice FROM products"
    > objConnection = New OleDbConnection(strConnect)
    > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > objCommand.Fill(DataSet1, "products")
    > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > DataGrid1.DataBind()
    >End Sub
    ></script>
    ><html>
    ><head>
    ><title>Data Grid Control Example</title>
    ></head>
    ><body>
    ><asp:DataGrid id="DataGrid1" runat="server" />
    ></body>
    ></html>
    >
    >However, if I open VS, ASP.net web application, go to the sourcecode view,
    >paste it in, I get a bunch of errors. It doesn't even recogize " <script
    >language="vb" runat="server"> "
    >
    >I know there has to be a way.
    >
    >Thanks
    >
    >Scott
    >
     
    Scott Allen, May 31, 2004
    #4
  5. SL

    SL Guest

    If I open VS, ASP.net web application, goto project/add html page/
    paste the code in place of what's there, I get no errors, just a browser
    with nothing on it.

    The first two lines are highlighted in yellow:
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>

    Thanks

    Scott



    "Ashish M Bhonkiya" <> wrote in message
    news:...
    > Hi,
    >
    > to use this file in vs.net you just create a new page
    > go to the designer in vs.net 2003 select HTML and paste the contents of

    this
    > file to the newly created page.
    >
    > thats all.
    >
    > i tried this and it for the following code and worked for me.
    > if you need you can go a head and put the code in the script tags to the
    > respective events in the codebehind file.
    >
    > Regards.
    > Ashish M Bhonkiya
    >
    > "SL" <> wrote in message
    > news:%...
    > > Could someone direct to a simple explanation of how to use MS Visual

    > Studio
    > > 2003 to design .aspx code?
    > > This code works if pasted into notepad and run as an .aspx file:
    > >
    > > <%@ Import Namespace="System.Data" %>
    > > <%@ Import Namespace="System.Data.OleDb" %>
    > > <script language="vb" runat="server">
    > > Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > > Dim objConnection As OleDBConnection
    > > Dim objCommand As OleDBDataAdapter
    > > Dim strConnect As String
    > > Dim strCommand As String
    > > Dim DataSet1 As New DataSet
    > >
    > > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    > > strConnect += "Persist Security Info=False"
    > >
    > > strCommand = "Select ProductName, UnitPrice FROM products"
    > > objConnection = New OleDbConnection(strConnect)
    > > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > > objCommand.Fill(DataSet1, "products")
    > > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > > DataGrid1.DataBind()
    > > End Sub
    > > </script>
    > > <html>
    > > <head>
    > > <title>Data Grid Control Example</title>
    > > </head>
    > > <body>
    > > <asp:DataGrid id="DataGrid1" runat="server" />
    > > </body>
    > > </html>
    > >
    > > However, if I open VS, ASP.net web application, go to the sourcecode

    view,
    > > paste it in, I get a bunch of errors. It doesn't even recogize "

    <script
    > > language="vb" runat="server"> "
    > >
    > > I know there has to be a way.
    > >
    > > Thanks
    > >
    > > Scott
    > >
    > >

    >
    >
     
    SL, May 31, 2004
    #5
  6. SL

    SL Guest

    Scott,
    I've trying pasting into the .vb file and I get errors. I've also tried
    adding an HTML page and it will run, but I get nothing but a blank browser.
    If I run the file from the brower (created by notepad) it works.

    I'm getting this code out of a Wrox book that doesn't even mention VS, so it
    was probably the wrong book, but I'd like to learn how to run the examples
    in VS if possible.

    Thanks

    Scott
    "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    news:...
    > Scott : Are you pasting the code into the "HTML view" of an ASPX page?
    > If you paste this code into a .vb file you'll have errors, it wasn't
    > clear what you mean by source code view.
    >
    >
    > --
    > Scott
    > http://www.OdeToCode.com
    >
    > On Mon, 31 May 2004 08:25:47 -0400, "SL" <> wrote:
    >
    > >Could someone direct to a simple explanation of how to use MS Visual

    Studio
    > >2003 to design .aspx code?
    > >This code works if pasted into notepad and run as an .aspx file:
    > >
    > ><%@ Import Namespace="System.Data" %>
    > ><%@ Import Namespace="System.Data.OleDb" %>
    > ><script language="vb" runat="server">
    > >Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > > Dim objConnection As OleDBConnection
    > > Dim objCommand As OleDBDataAdapter
    > > Dim strConnect As String
    > > Dim strCommand As String
    > > Dim DataSet1 As New DataSet
    > >
    > > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    > > strConnect += "Persist Security Info=False"
    > >
    > > strCommand = "Select ProductName, UnitPrice FROM products"
    > > objConnection = New OleDbConnection(strConnect)
    > > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > > objCommand.Fill(DataSet1, "products")
    > > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > > DataGrid1.DataBind()
    > >End Sub
    > ></script>
    > ><html>
    > ><head>
    > ><title>Data Grid Control Example</title>
    > ></head>
    > ><body>
    > ><asp:DataGrid id="DataGrid1" runat="server" />
    > ></body>
    > ></html>
    > >
    > >However, if I open VS, ASP.net web application, go to the sourcecode

    view,
    > >paste it in, I get a bunch of errors. It doesn't even recogize "

    <script
    > >language="vb" runat="server"> "
    > >
    > >I know there has to be a way.
    > >
    > >Thanks
    > >
    > >Scott
    > >

    >
     
    SL, May 31, 2004
    #6
  7. SL

    Scott Allen Guest

    Hi Scott:

    One of the problems is that this code belongs in an ASPX page without
    a code behind file. By default VS.NET creates ASPX pages with a code
    behind file.

    Save the code you have below into a file with an ASPX extension. In
    Visual Studio.NET you can right click a web project in Solution
    Explorer and select "Add" -> "Add Existing Item" from the context
    menu, then add the aspx file you've created. If VS.NET prompts you to
    create a code behind file, answer no. You should be able to start
    debugging and step through the code. Or right click the aspx in
    solution explorer and select "View In Browser".

    HTH,

    --
    Scott
    http://www.OdeToCode.com

    On Mon, 31 May 2004 14:58:24 -0400, "SL" <> wrote:

    >Scott,
    >I've trying pasting into the .vb file and I get errors. I've also tried
    >adding an HTML page and it will run, but I get nothing but a blank browser.
    >If I run the file from the brower (created by notepad) it works.
    >
    >I'm getting this code out of a Wrox book that doesn't even mention VS, so it
    >was probably the wrong book, but I'd like to learn how to run the examples
    >in VS if possible.
    >
    >Thanks
    >
    >Scott
    >"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    >news:...
    >> Scott : Are you pasting the code into the "HTML view" of an ASPX page?
    >> If you paste this code into a .vb file you'll have errors, it wasn't
    >> clear what you mean by source code view.
    >>
    >>
    >> --
    >> Scott
    >> http://www.OdeToCode.com
    >>
    >> On Mon, 31 May 2004 08:25:47 -0400, "SL" <> wrote:
    >>
    >> >Could someone direct to a simple explanation of how to use MS Visual

    >Studio
    >> >2003 to design .aspx code?
    >> >This code works if pasted into notepad and run as an .aspx file:
    >> >
    >> ><%@ Import Namespace="System.Data" %>
    >> ><%@ Import Namespace="System.Data.OleDb" %>
    >> ><script language="vb" runat="server">
    >> >Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    >> > Dim objConnection As OleDBConnection
    >> > Dim objCommand As OleDBDataAdapter
    >> > Dim strConnect As String
    >> > Dim strCommand As String
    >> > Dim DataSet1 As New DataSet
    >> >
    >> > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    >> > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb; "
    >> > strConnect += "Persist Security Info=False"
    >> >
    >> > strCommand = "Select ProductName, UnitPrice FROM products"
    >> > objConnection = New OleDbConnection(strConnect)
    >> > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    >> > objCommand.Fill(DataSet1, "products")
    >> > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    >> > DataGrid1.DataBind()
    >> >End Sub
    >> ></script>
    >> ><html>
    >> ><head>
    >> ><title>Data Grid Control Example</title>
    >> ></head>
    >> ><body>
    >> ><asp:DataGrid id="DataGrid1" runat="server" />
    >> ></body>
    >> ></html>
    >> >
    >> >However, if I open VS, ASP.net web application, go to the sourcecode

    >view,
    >> >paste it in, I get a bunch of errors. It doesn't even recogize "

    ><script
    >> >language="vb" runat="server"> "
    >> >
    >> >I know there has to be a way.
    >> >
    >> >Thanks
    >> >
    >> >Scott
    >> >

    >>

    >
     
    Scott Allen, Jun 1, 2004
    #7
  8. Hi,
    > If I open VS, ASP.net web application, goto project/add html page/
    > paste the code in place of what's there, I get no errors, just a browser
    > with nothing on it.


    You need to add a webform and not and HTML Page. and repeat the same steps,
    that should help.

    Regards
    Ashish M Bhonkiya

    "SL" <> wrote in message
    news:...
    > If I open VS, ASP.net web application, goto project/add html page/
    > paste the code in place of what's there, I get no errors, just a browser
    > with nothing on it.
    >
    > The first two lines are highlighted in yellow:
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Data.OleDb" %>
    >
    > Thanks
    >
    > Scott
    >
    >
    >
    > "Ashish M Bhonkiya" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > to use this file in vs.net you just create a new page
    > > go to the designer in vs.net 2003 select HTML and paste the contents of

    > this
    > > file to the newly created page.
    > >
    > > thats all.
    > >
    > > i tried this and it for the following code and worked for me.
    > > if you need you can go a head and put the code in the script tags to the
    > > respective events in the codebehind file.
    > >
    > > Regards.
    > > Ashish M Bhonkiya
    > >
    > > "SL" <> wrote in message
    > > news:%...
    > > > Could someone direct to a simple explanation of how to use MS Visual

    > > Studio
    > > > 2003 to design .aspx code?
    > > > This code works if pasted into notepad and run as an .aspx file:
    > > >
    > > > <%@ Import Namespace="System.Data" %>
    > > > <%@ Import Namespace="System.Data.OleDb" %>
    > > > <script language="vb" runat="server">
    > > > Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    > > > Dim objConnection As OleDBConnection
    > > > Dim objCommand As OleDBDataAdapter
    > > > Dim strConnect As String
    > > > Dim strCommand As String
    > > > Dim DataSet1 As New DataSet
    > > >
    > > > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; "
    > > > strConnect += "Data Source =C:\Sample ASPNet\Ch02\grocertogo.mdb;

    "
    > > > strConnect += "Persist Security Info=False"
    > > >
    > > > strCommand = "Select ProductName, UnitPrice FROM products"
    > > > objConnection = New OleDbConnection(strConnect)
    > > > objCommand = New OleDbDataAdapter(strCommand, ObjConnection)
    > > > objCommand.Fill(DataSet1, "products")
    > > > DataGrid1.DataSource = DataSet1.Tables("Products").DefaultView
    > > > DataGrid1.DataBind()
    > > > End Sub
    > > > </script>
    > > > <html>
    > > > <head>
    > > > <title>Data Grid Control Example</title>
    > > > </head>
    > > > <body>
    > > > <asp:DataGrid id="DataGrid1" runat="server" />
    > > > </body>
    > > > </html>
    > > >
    > > > However, if I open VS, ASP.net web application, go to the sourcecode

    > view,
    > > > paste it in, I get a bunch of errors. It doesn't even recogize "

    > <script
    > > > language="vb" runat="server"> "
    > > >
    > > > I know there has to be a way.
    > > >
    > > > Thanks
    > > >
    > > > Scott
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ashish M Bhonkiya, Jun 1, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    481
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,628
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    425
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    516
    Dave Thompson
    Feb 14, 2005
  5. olivier.melcher

    Help running a very very very simple code

    olivier.melcher, May 12, 2008, in forum: Java
    Replies:
    8
    Views:
    2,299
Loading...

Share This Page