4 Replies - 456 Views - Last Post: 24 December 2018 - 01:35 PM

#1 HorribleProgrammer808   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 21-December 18

GridView CRUD application from tutorial has multiple errors

Posted 23 December 2018 - 08:33 PM

Hello,

For my new job, I was told to create/learn how to create a Web form attached to a SQL Server database using VB.NET, JS and HTML, and I have been stuck for a week. Yesterday I scrapped my project and then followed this tutorial, but obviously I changed the connection strings, and the file names, etc. The grideview looks good, but I have 40+ errors that say "xxx type is not a member of xxx". I plan on re-designing once I get it to work, and I will not be claiming this as my own work; my boss said I can use other's code that works, however he did not want me to use any controls or add-ons, but I had no idea how to create a CRUD form without GridView, which every VB.NET/SQL/CRUD app tutorial uses.


I would truly appreciate any help... Here is the code:


ASPX File
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="CustomerId"
        OnRowDataBound="OnRowDataBound" OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit"
        OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting" EmptyDataText="No records has been added.">
        <Columns>
            <asp:TemplateField HeaderText="Name" ItemStyle-Width="150">
                <ItemTemplate>
                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Country" ItemStyle-Width="150">
                <ItemTemplate>
                    <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Country") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtCountry" runat="server" Text='<%# Eval("Country") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true"
                ItemStyle-Width="150" />
        </Columns>
    </asp:GridView>


VB File
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports System
Imports System.Web.UI.WebControls

Partial Class VB
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Me.BindGrid()
        End If
    End Sub

    Private Sub BindGrid()
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand("Customers_CRUD")
                cmd.Parameters.AddWithValue("@Action", "SELECT")
                Using sda As New SqlDataAdapter()
                    cmd.CommandType = CommandType.StoredProcedure
                    cmd.Connection = con
                    sda.SelectCommand = cmd
                    Using dt As New DataTable()
                        sda.Fill(dt)
                        GridView1.DataSource = dt
                        GridView1.DataBind()
                    End Using
                End Using
            End Using
        End Using
    End Sub

    Protected Sub Insert(sender As Object, e As EventArgs)
        Dim name As String = txtName.Text
        Dim country As String = txtCountry.Text
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand("Customers_CRUD")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@Action", "INSERT")
                cmd.Parameters.AddWithValue("@Name", name)
                cmd.Parameters.AddWithValue("@Country", country)
                cmd.Connection = con
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using
        Me.BindGrid()
    End Sub

    Protected Sub OnRowEditing(sender As Object, e As GridViewEditEventArgs)
        GridView1.EditIndex = e.NewEditIndex
        Me.BindGrid()
    End Sub

    Protected Sub OnRowCancelingEdit(sender As Object, e As EventArgs)
        GridView1.EditIndex = -1
        Me.BindGrid()
    End Sub

    Protected Sub OnRowUpdating(sender As Object, e As GridViewUpdateEventArgs)
        Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
        Dim customerId As Integer = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Values(0))
        Dim name As String = TryCast(row.FindControl("txtName"), TextBox).Text
        Dim country As String = TryCast(row.FindControl("txtCountry"), TextBox).Text
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand("Customers_CRUD")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@Action", "UPDATE")
                cmd.Parameters.AddWithValue("@CustomerId", customerId)
                cmd.Parameters.AddWithValue("@Name", name)
                cmd.Parameters.AddWithValue("@Country", country)
                cmd.Connection = con
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using
        GridView1.EditIndex = -1
        Me.BindGrid()
    End Sub

    Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow AndAlso e.Row.RowIndex <> GridView1.EditIndex Then
            TryCast(e.Row.Cells(2).Controls(2), LinkButton).Attributes("onclick") = "return confirm('Do you want to delete this row?');"
        End If
    End Sub

    Protected Sub OnRowDeleting(sender As Object, e As GridViewDeleteEventArgs)
        Dim customerId As Integer = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Values(0))
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand("Customers_CRUD")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@Action", "DELETE")
                cmd.Parameters.AddWithValue("@CustomerId", customerId)
                cmd.Connection = con
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using
        Me.BindGrid()
    End Sub

    Private Function GridView1() As Object
        Throw New NotImplementedException
    End Function

    Private Function txtName() As Object
        Throw New NotImplementedException
    End Function

    Private Function txtCountry() As Object
        Throw New NotImplementedException
    End Function

End Class



Web Config
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="constr" connectionString="Data Source=DESKTOP-2152UP5\SQLEXPRESS;Initial Catalog=Employee;Integrated Security=True"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>



I already connected my SQL server database that I created days ago, to Server Explorer.

Is This A Good Question/Topic? 0
  • +

Replies To: GridView CRUD application from tutorial has multiple errors

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15275
  • View blog
  • Posts: 61,238
  • Joined: 12-June 08

Re: GridView CRUD application from tutorial has multiple errors

Posted 23 December 2018 - 08:40 PM

Please copy/paste the complete errors here.

Moving to ASP.NEt
Was This Post Helpful? 0
  • +
  • -

#3 HorribleProgrammer808   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 21-December 18

Re: GridView CRUD application from tutorial has multiple errors

Posted 23 December 2018 - 09:11 PM

Errors:

Quote

Error 1 'Context' is not a member of 'VB'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 80
Error 2 'Context' is not a member of 'VB'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 86
Error 3 Class 'vb_aspx' must implement 'ReadOnly Property IsReusable As Boolean' for interface 'System.Web.IHttpHandler'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 96
Error 4 Class 'vb_aspx' must implement 'Sub ProcessRequest(context As HttpContext)' for interface 'System.Web.IHttpHandler'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 96
Error 5 'GetWrappedFileDependencies' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 117
Error 6 'Server' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 120
Error 7 property 'SupportAutoEvents' cannot be declared 'Overrides' because it does not override a property in a base class. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 123
Error 8 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 242
Error 9 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 255
Error 10 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 256
Error 11 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 295
Error 12 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 342
Error 13 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 355
Error 14 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 356
Error 15 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 395
Error 16 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 473
Error 17 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 486
Error 18 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 487
Error 19 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 526
Error 20 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 573
Error 21 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 586
Error 22 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 587
Error 23 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.TemplateControl'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 626
Error 24 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 777
Error 25 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 851
Error 26 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 884
Error 27 Value of type 'ASP.vb_aspx' cannot be converted to 'System.Web.UI.Page'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 916
Error 28 function 'GetTypeHashCode' cannot be declared 'Overrides' because it does not override a function in a base class. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 1148
Error 29 sub 'ProcessRequest' cannot be declared 'Overrides' because it does not override a sub in a base class. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 1153
Error 30 'ProcessRequest' is not a member of 'VB'. C:\Users\pleil\AppData\Local\Temp\Temporary ASP.NET Files\root\5b086da6\ba80610d\App_Web_zyetz5it.0.vb 1154
Error 31 'InitializeCulture' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 1
Error 32 'OnRowEditing' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 34
Error 33 'OnRowDeleting' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 34
Error 34 'OnRowUpdating' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 34
Error 35 'OnRowDataBound' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 34
Error 36 'OnRowCancelingEdit' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 34
Error 37 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 40
Error 38 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 43
Error 39 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 48
Error 40 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 51
Error 41 'Insert' is not a member of 'ASP.vb_aspx'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 69
Error 42 Unable to open module file 'C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\Default.aspx.vb': The system cannot find the file specified. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\Default.aspx.vb 1 1 WebSite10
Error 43 'Context' is not a member of 'VB'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 40 66 WebSite10
Error 44 'Context' is not a member of 'VB'. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 40 66 WebSite10
Error 45 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 40 70 WebSite10
Error 46 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 43 72 WebSite10
Error 47 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 48 73 WebSite10
Error 48 'Eval' is not declared. It may be inaccessible due to its protection level. C:\Users\pleil\Documents\Visual Studio 2012\WebSites\WebSite10\VB.aspx 51 75 WebSite10

Was This Post Helpful? 0
  • +
  • -

#4 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: GridView CRUD application from tutorial has multiple errors

Posted 24 December 2018 - 07:22 AM

What is on that line (80) in App_Web_zyetz5it.0.vb?

Taking a stab in the dark, but you may be missing some inheritance, or has this only happened since putting it live?>
Was This Post Helpful? 0
  • +
  • -

#5 HorribleProgrammer808   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 21-December 18

Re: GridView CRUD application from tutorial has multiple errors

Posted 24 December 2018 - 01:35 PM

View PostSheepings, on 24 December 2018 - 07:22 AM, said:

What is on that line (80) in App_Web_zyetz5it.0.vb?

Taking a stab in the dark, but you may be missing some inheritance, or has this only happened since putting it live?>

That line is a file that is automatically generated by VS when errors occur. I is like an error log of some sort. And yes, this has only happened since debugging. I use VS 22012, by the way if that helps. Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1