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

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

VS2008 SQL Statement

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
Are we entering the correct SQL Statement in both VS2008 and Web Hosting Account (View snapshots at http://cforedu.com/snap.pdf) to match with the SQL Statement found in the following C# code (i.e., SqlDbType = SqlDbType.Int):  protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlapplicationConnectionString"].ToString()); try { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO Application (" + " First, Last, City, State" + ") VALUES (" + " @First, @Last, @City, @State"; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@First", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["First"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Last", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["Last"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@City",

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?


crystal reports on mvc 2 vs2008


hi, i'm a new user of mvc 2, so, i need to use crystal reports on mvc 2, actually, i'm developing on visual studio 2008, but i can´t run my reports. it's posible run my reports???

thank you very much.

web deployment project (WS_deploy) on VS2008


I am building a asp.net webservice in VS2008 and the web service compiles and debug fine. The project should be using : Net 3,5

 I have

  1. VS2005 and VS208 installed
  2. .Net 1.1 - 3.5
  3. WebDeploymentSetup for VS2008 (and most likely a version for VS2005 as well)

But when I add a web deployment project the fun stops. The .WS_deploy project will not compile and I cannot find any precompiled output.

--------------debug output-------------------

------ Build started: Project: **************.DAL, Configuration: Debug Any CPU ------
Build started 13-08-2010 08:17:14.
Target EntityDeploy:
    Processing 0 EDMX files.
    Finished processing 0 EDMX files.
Target CoreResGen:
    No resources are out of date with respect to their source files. Skipping resource generation.
Target CopyFilesToOutputDirectory:
    **************.DAL -> C:\Development\VS2008\**************\**************.DAL\bin\Debug\**************.DAL.dll

Build succeeded.

Time Elapsed 00:00:00.14
------ Build started: Project: **************.BLL, Configuration: Debug Any CPU ------
Build started 13-08-2010 08:17:14.
Target EntityDeploy:
    Processing 0 EDMX files.
    Finished processing 0 EDMX files.
Target ResolveProjectReferences:
Target CoreResGen:
    No resources are out of

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.

    Team System - VS2008 -- Performance testing statistics


    Dear all,


    I am new to using performance testing in team system VS2008.

    Could you tell me that What is the steps needed in VS2008 to create performance testing if I have the Web Application Source Code??

    So that I can know where or which function need the most time. 

    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 = _
    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