.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Need help with DAL using statement

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

I am trying to build a little ASP.NET 3.5 project to explore DAL concepts.  While following the steps on this walkthrough:


I am unable to figure out how to reference the TableAdapter added in the DAL section from within the App_Code directory.  I tried adding the following different statements

  using AccountsTableAdapter

  using <projectname>.App_Code.MyTableAdpater

where <projectname> is the solution name.  When I add this to the code behind page but I keep getting an error regarding the namespace.  What is the pattern I need to use to find this code in 3.5 within the App_Code directory? 


View Complete Post

More Related Resource Links

Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


ReportViewer :: Failed to enable constraints. But my statement is valid!!

  • A
  • n error has occurred during report processing.
      • Exception has been thrown by the target of an invocation.
        • Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Why do I keep getting this error, even when not using any data on the report. When I run the query in SQL server I get a resultset. However when I try to render the report I get this error.


    Whats wrong with this statement


    Im trying to updated some old ASP pages with some new .net pages and cant seem to get this update statement to work. I need to update the current ASP code below and then once thats working im going to use that same statement in a procedure for all our new .Net pages..

    So can anyone see what im doing wrong by inserting the 2nd column to the update statement?

    strSqual = "update tas set date_completed='" & TransDate & ", trans_id=" & InsertedTransID & "' where date_completed is null and sercontract_id="& strContractID & " and DATEDIFF(dd,task_due_date,'" & strProcDate & "')<=14"


    I am trying to add an extra column to the update, but not sure if the syntax is correct.

    If Statement Issue



    This is very strange to me. I have spent 2hrs looking into this inside out , but dont seem to get it

    I have an if statement that inserts data into the database. But i check to make sure the name is not entered twice. Now when the name is already in the db, then it should insert else put out a message saying its already in the db

    My code works fine except that  when its not in the db, its inserts but still puts out the message that says "Name is already in use" Not sure if am not seeing something. But thought i did bring it to the forum. Here is my code...Pretty simple

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

            Dim objConnection As SqlConnection
            Dim objCommand As SqlCommand
            Dim strSQLQuery1 As String


            ' If there's nothing to Add for then don't search
            ' o/w build our SQL Query and execute it.
            If String.IsNullOrEmpty(txtAdd.Text) Or Leadbank.SelectedValue = "000" Then


    statement cannot appear outside of a method body


    hi all,

      i am posting my vb.net problem .plz tell me how to resolve this :-

    Dim conn As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
        'Dim mysqlconnection As New SqlConnection(conn)
        'If mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();
        'Dim mySqlcommand As New SqlCommand("select CategoryId,CategoryName from Categories", mysqlconnection)
        'Dim mySqlDataAdapter As New SqlDataAdapter(mySqlcommand)
        'Dim mydataSet As New DataSet()

        'if mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();

    i m getting 5 errors in this code

    declaration expected in mySqlDataAdapter.Fill method; Gridview1.DataSource=ds; Gridview1.DataBind();

    how to multiple condition in if statement in asp.net C#



    i am using if condition to find out a time

    if(time=="08 AM)


    response.write"shift A";


    but problem is how can i put multiple condition in if like

    if(time=="06 AM" and "08 AM" and "07 AM")



    Hello, i need help changing the following code into a switch...case statementUndecided

    <script runat="server">
    void Page_Load()
        if (Page.IsPostBack)
        public String toSring()
        int intcomputerChoice=1;
           if (Page.IsPostBack)

    Using a If Else Statement


    I'm working in a Wizard control and need a little help. I'm pulling in a labels text through a databound field and if it equals a certain text then I need a textbox field to be less than or equal to a certain amount. I would also like to have a message appear to prompt the user that an invalid number has been entered. I'm not sure how to go about this. Is it better to use client side javascript or use page load and perform some kind of control validation. The code I've tried isn't working so any help would be greatly appreciated.

    For instance...

    Protected Sub Page_Load(ByVal Sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If label1 = "Refrigerator" then

    TextBox1 <= "700"

    Else Label1 = "Washer" then

    TextBox1 <= "500"

    End if

    End Sub

    The statement terminated. The maximum recursion 100 has been exhausted before statement completion.


    Hi All

    I have the below sql scripts that give me the error:
    "The statement terminated. The maximum recursion 100 has been exhausted before statement completion."

    Ive tried using OPTION ( MAXRECURSION 0 ) or 1000 but it still  give me the same error.

    WITH cte as (SELECT     ticketid, setstatus, setdate, row_number() OVER (partition BY (ticketid)
    ORDER BY setdate ASC) AS rn
    FROM         [OneForm].[dbo].[TFAM_SLA_Times]
    SELECT     TicketID, 'Submitted', SubmittedON, 0
    FROM         [OneForm].[dbo].vw_TFAM_ALL)
        SELECT     a.ticketid, SUM(OneForm.dbo.[CalcMinutesSLA_TFAM](a.setdate, b.setdate)) AS SLA_in_Min
         FROM         vw_TFAM_SLA_Combined AS a LEFT JOIN
                                vw_TFAM_SLA_Combined AS b ON a.ticketid = b.ticketid AND a.rn = b.rn - 1
         WHERE     (a.SetStatus = 'Submitted' OR
                                a.SetStatus = 'Acknowledged' OR
                                a.SetStatus = 'Pending')
         GROUP BY a.TicketID

    If i remove the call to the function [CalcMinutesSLA_TFAM] or the b.rn - 1 it works fine.

    Here is the code for the function:

    CREATE FUNCTION [dbo].[CalcMinutesSLA2

    Where to place if statement


    I have a design problem I could use some help determining how to code this problem.

    I have a table with 3 fields, catCode, startDate and endDate. I am having trouble deciding how to query my DB based on the following...

    By default a gridview will return all records that match the catCode selected from a dropdown list.


    If the user checks a check box, only records are returned where....

    startDate <= today AND endDate >= today


    How can I apply the If condition to compare when the check box is selected? I used the wizard to build the select statment for the gridview, but I can switch that to a SP if that makes life easier.


    Thanks for any and all help and suggestions.

    The DELETE statement conflicted with the REFERENCE constraint


    I have created ASP.Net Dynamic data web site using scaffolding in Visual Studio 2010. When I click on delete in data grid for customer table I got below error message.

    The DELETE statement conflicted with the REFERENCE constraint "FK_Order_Details_Products". The conflict occured in database "../NORTHWIND.MDF", table "dbo.order details", column 'ProductId'

    The statement has been terminated


    SQL statement to get data like outlook


     I have been struggling to write an sql statement that will give me data like outlook format., especially in term of grouping like





    Last week

    two weeks ago

    Last Month


    Is there anyone that can help me on this please? I appreciated

    XML Repeater Inside Conditional Statement


    Hi all,

    I'm working on an VB.Net application which have 2 nasted repeaters using xml as data source. I need to add a conditional statement withen the first repeater ItemTemplate as follows:

    	<%# IIf(XPath("@type")= 3 , "<html>", "<div id=""tblPages"" runat=""server""><divsub""><h2>"   &  XPath("@title") &  "</h2><ul class="sublinks"><asp:repeater id=""rpPages"" DataSource=""XPathSelect("@page")"" runat=""server""><ItemTemplate><li></li></ItemTemplate></asp:Repeater></ul></div></div>" ) %>

    The problem come when I  try to add the

    DataSource='<%# XPathSelect("page") %>'

    so I get an error.

    Does anyone have idea if the above code may work?

    thank you

    Case statement is never executing


    Can some please advise as to why the case statement is never running


    Imports Microsoft.VisualBasic
    Imports AjaxControlToolkit
    Public Class MultilevelAccordion
        Inherits System.Web.UI.UserControl
        Implements System.Web.UI.ITemplate
        Dim templateType As AccordionItemType
        Sub New(ByVal type As AccordionItemType)
            templateType = type
        End Sub
        Sub New()
        End Sub
        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
              Implements System.Web.UI.ITemplate.InstantiateIn
            Dim ph As New PlaceHolder()
            Select Case (templateType)
                Case AccordionItemType.Header
                    Dim myLabel As Label = New Label()
                    myLabel.ID = "HeaderLabel"
                    AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
                Case AccordionItemType.Content
                    AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
            End Select
        End Sub
        Shared Sub Item_DataBinding(ByVal sender As Object, ByVal e As AccordionItemEventArgs)
            Dim ph As PlaceHolder = CType(sender, PlaceHolder)
            Dim headerValue As String = _

    web services transactions (select statement)

     Hi everybody, i'm just getting started in web services and i have a problem connecting to a database. All i want is that my web service recieves a string parameter and return a dataset so that in the client aplication i just show the result of the web service in a datagrid. Here's the code of the web service:    <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" %> using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Linq;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Xml.Linq;using System.EnterpriseServices;using System.Data.SqlClient;namespace Farmacia{    [WebService(Namespace = "http://localhost/MyWebServices")]    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]    [ToolboxItem(false)]    public class Farmacia : System.Web.Services.WebService    {        private SqlDataAdapter da;        [WebMethod(TransactionOption=TransactionOption.RequiresNew)]        public DataSet Consultas (string sel)        {            if (sel == "")&

    LINQ to SQL and Case statement

    Working with LINQ I realized that I had to use the simple case statement in my SQL query. There is no special keyword for this. To create a case statement like structure you will have to do it in the select section of the query. Below is an example of the usage of the case statement in LINQ. var t = from n in idc.categories            select new             {                        catName =                         (n.id==1 ? "Cat1" :                        n.id==2 ? "Cat2" :                        n.id==3 ? "Cat3" : "Unknown Category"                        )             }; Here in the above code we are using multiple cases for value 1, 2 and 3

    MDX statement to retrieve only one value

    Hi all, SELECT [Measures].MEMBERS ON COLUMNS, NON EMPTY [0VENDOR].[LEVEL01].MEMBERS DIMENSION PROPERTIES [0VENDOR].[20VENDOR] ON ROWS FROM [OPOMCHS0/ZQT_GPO_PO_CHNG_REP_SUMM_3] . The balove statement gives me all the values of the vendors. What if I want this statement to retrieve only a vendor called ABCD? Thanks in advance.  
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend