Quantcast
Channel: DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Viewing all 956 articles
Browse latest View live

Error...No value given for one or more required parameters

$
0
0

I'm trying to add to a website a section that will allow a user to button click after selecting 2 dates, text boxes txtFrom and txtTo, from a date picker which will run the queries created to pull the info from a DB, the code runs perfect binding the data to a gridview without the date selection. My issue is getting the date function to work. When I click submit I receive a "No value given for one or more required parameters" error message, I'm hoping somebody can point me in the right direction here.

Heres what it looks like:

display

Here is the  C# code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.OleDb;
using System.Net;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class Reports_frmMonthlyRepoTotals : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private static string GetDataConnection()
    {
        string cnnString = string.Empty;

        cnnString = ConfigurationManager.ConnectionStrings["KBSystem_DBConnectionString"].ConnectionString;

        return cnnString;

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        
            OleDbDataAdapter sqlDA;
            OleDbConnection sqlConn;
            OleDbConnection conn = new OleDbConnection(GetDataConnection());

            sqlConn = new OleDbConnection(GetDataConnection());
            {
                conn.Open();
            }
            OleDbCommand command = conn.CreateCommand();


            sqlDA = new OleDbDataAdapter("SELECT RepoDate, AlscoInvoice, WorkType, VinNum, OrderYear, OrderMake, OrderModel, Debtor, RepoAgent, PayOut, InvoiceEntered FROM tblPersonnel WHERE txtFrom='@txtFrom' AND txtTo='@txtTo' AND WorkType='Voluntary' Or WorkType='Involuntary' AND RepoAgent='Aaron' Or RepoAgent='Keith' Or RepoAgent='Jimmy'", sqlConn);
            command.Parameters.AddWithValue("@txtFrom", txtFrom.Text);
            command.Parameters.AddWithValue("@txtTo", txtTo.Text);

            DataTable dt = new DataTable();
            sqlDA.Fill(dt);


            if (dt.Rows.Count > 0)
            {
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
            conn.Close();
    }
}

<div data-url="https://forums.asp.net/post/set/54/0/0" style="display: none;" id="link64_adl_tabid">591</div>

ObjectDataSource.FilterExpression must not contain function calls - alternatives?

$
0
0

Hi,

I have an ObjectDataSource that fills a ListView. When the user changes some filter criteria, I used to change the its FilterExpression accordingly, and the ListView immediately changed its content.

Now I need a filter condition with a function, and I noticed that the FilterExpression must not contain function calls. It even cannot have an EXISTS call.

What else can I do?

Thanks
Magnus

Multiple select queries in SQL data source

$
0
0

Can we add multple select queries in sql data source

Problem with ObjectDataSource after database change

$
0
0

Hello,

I have made a change to my database design: I renamed one column in a table.

After that, I get the following exception. I updated the underlying dataset, but the error does not disappear.

I have already updated and regenerated the query inside the DataSet.

My problem is that the error messages do not provide enough information for me to locate the source of the problem.
What can I do to get more concrete information?

Thanks
Magnus

Server Error in '/' Application.

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Source Error: 



Line 3139:            this.Adapter.SelectCommand = this.CommandCollection[0];
Line 3140:            rmv.RaumViewDataTable dataTable = new rmv.RaumViewDataTable();
Line 3141:            this.Adapter.Fill(dataTable);
Line 3142:            return dataTable;
Line 3143:        }
  

 Source File:  f:\dvl\prj\Governica\Governica\dbs\dts\rmv.Designer.cs    Line:  3141 

Stack Trace: 



[ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.]
   System.Data.DataTable.EnableConstraints() +2020339
   System.Data.DataTable.set_EnforceConstraints(Boolean value) +39
   System.Data.DataTable.EndLoadData() +234
   System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +213
   System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +349
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +219
   System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +160
   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +108
   Governica.dbs.dts.rmvTableAdapters.RaumViewTableAdapter.GetData() in f:\dvl\prj\Governica\Governica\dbs\dts\rmv.Designer.cs:3141

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +486
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1609
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
   System.Web.UI.WebControls.ListView.PerformSelect() +167
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.ListView.CreateChildControls() +122
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

  


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248  

admin panel login error message

MVC Music Store database connection issue

$
0
0

Hello, I really need some help for Music Store tutorial...I am following the asp.net MvcMusicStore tutorial and everything works fine but the data is not adding to MvcMusicStore.sdf...This is the page with that part of the tutorial that makes the connection to database: http://www.asp.net/mvc/overview/older-versions/mvc-music-store/mvc-music-store-part-4 The expected result should return a list with all of genres, but in my case I'm getting NULL values in MvcMusicStore.sdf Genres table.

I downloaded the completed tutorial and everything works fine there, all data values are inserted to database tables..

SampleData.cs:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Data.Entity;namespaceMvcMusicStore.Models{publicclassSampleData:DropCreateDatabaseIfModelChanges<MusicStoreEntities>{protectedoverridevoidSeed(MusicStoreEntities context){var genres =newList<Genre>{newGenre{Name="Rock"},newGenre{Name="Jazz"},newGenre{Name="Metal"}};var artists =newList<Artist>{newArtist{Name="Aaron Copland & London Symphony Orchestra"},newArtist{Name="Aaron Goldberg"}};newList<Album>{newAlbum{Title="A Copland Celebration, Vol. I",Genre= genres.Single(g => g.Name=="Classical"),Price=8.99M,Artist= artists.Single(a => a.Name=="Aaron Copland & London Symphony Orchestra"),AlbumArtUrl="/Content/Images/placeholder.gif"},}.ForEach(a => context.Albums.Add(a));}}}

Web.config:

<connectionStrings><addname="MusicStoreEntities"connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"providerName="System.Data.SqlServerCe.4.0"/></connectionStrings>

Global.asax

protectedvoidApplication_Start(){System.Data.Entity.Database.SetInitializer(newMvcMusicStore.Models.SampleData());AreaRegistration.RegisterAllAreas();RegisterGlobalFilters(GlobalFilters.Filters);RegisterRoutes(RouteTable.Routes);}

Genre.cs

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;namespaceMvcMusicStore.Models{publicpartialclassGenre{publicintGenreId{get;set;}publicstringName{get;set;}publicstringDescription{get;set;}publicList<Album>Albums{get;set;}}}

Operator '&&' cannot be applied to operands of type 'bool' and 'System.Collections.Generic.IEnumerable'

$
0
0
   project = db.Project.Where(c => c.ID == id && c.ProjectTasks.Select(a => a.isCompleted == false)).
     Include(c => c.ProjectTasks.Select(b => b.ProjectTaskProgresses)).
   Include(c => c.ProjectTasks.Select(a => a.ProjectTaskLeads)).
   SingleOrDefault();

Help! I want to select all completed tasks within a project. Here is my code. 

Error with delete and update

$
0
0
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" 
        SelectCommand="SELECT TicketsDetail.Complete, TicketsDetail.TicketID, TicketsDetail.Description, TicketsDetail.DepartmentID, TicketsDetail.Priority, TicketsDetail.CreatorID, TicketsDetail.AssignedToID, TicketsDetail.Date, Departments.Department, TicketsDetail.GroupID, TicketsDetail.CustomerID, TicketsDetail.DateCompleted, TicketsDetail.Details, TicketsDetail.CatagoryID, Customers.CustomerName, [Group].GroupName, Creator.CreatorName, TicketsDetail.DueDate FROM TicketsDetail INNER JOIN Departments ON TicketsDetail.DepartmentID = Departments.DepartmentID INNER JOIN Customers ON TicketsDetail.CustomerID = Customers.CustomerID INNER JOIN [Group] ON TicketsDetail.GroupID = [Group].GroupID INNER JOIN Creator ON TicketsDetail.CreatorID = Creator.CreatorID WHERE (TicketsDetail.Complete = @Complete)"
        ConflictDetection="CompareAllValues" 

        DeleteCommand="DELETE FROM TicketsDetail WHERE (TicketID = @original_TicketID) AND (Description = @original_Description OR Description IS NULL AND @original_Description IS NULL) AND (DepartmentID = @original_DepartmentID OR DepartmentID IS NULL AND @original_DepartmentID IS NULL) AND (Priority = @original_Priority OR Priority IS NULL AND @original_Priority IS NULL) AND (CreatorID = @original_CreatorID OR CreatorID IS NULL AND @original_CreatorID IS NULL) AND (AssignedToID = @original_AssignedToID OR AssignedToID IS NULL AND @original_AssignedToID IS NULL) AND (Date = @original_Date OR Date IS NULL AND @original_Date IS NULL) AND (GroupID = @original_GroupID OR GroupID IS NULL AND @original_GroupID IS NULL) AND (CustomerID = @original_CustomerID OR CustomerID IS NULL AND @original_CustomerID IS NULL) AND (DateCompleted = @original_DateCompleted OR DateCompleted IS NULL AND @original_DateCompleted IS NULL) AND (Complete = @original_Complete OR Complete IS NULL AND @original_Complete IS NULL) AND (CatagoryID = @original_CatagoryID OR CatagoryID IS NULL AND @original_CatagoryID IS NULL) AND (DueDate = @original_DueDate OR DueDate IS NULL AND @original_DueDate IS NULL)"         InsertCommand="INSERT INTO TicketsDetail(Complete, Description, DepartmentID, Priority, CreatorID, AssignedToID, Date, GroupID, CustomerID, CagoryID, Details, DateCompleted, CatagoryID, DueDate) VALUES (@Complete, @Description, @DepartmentID, @Priority, @CreatorID, @AssignedToID, @Date, @GroupID, @CustomerID, @CatagoryID, @Details, @DateCompleted,,)" 
        OldValuesParameterFormatString="original_{0}" 
        UpdateCommand="UPDATE [TicketsDetail] SET [DueDate] = @DueDate, [DateCompleted] = @DateCompleted, [Details] = @Details, [CatagoryID] = @CatagoryID, [Complete] = @Complete, [CustomerID] = @CustomerID, [GroupID] = @GroupID, [AssignedToID] = @AssignedToID, [CreatorID] = @CreatorID, [Priority] = @Priority, [DepartmentID] = @DepartmentID, [Description] = @Description, [Date] = @Date WHERE [TicketID] = @original_TicketID AND (([DueDate] = @original_DueDate) OR ([DueDate] IS NULL AND @original_DueDate IS NULL)) AND (([DateCompleted] = @original_DateCompleted) OR ([DateCompleted] IS NULL AND @original_DateCompleted IS NULL)) AND (([Details] = @original_Details) OR ([Details] IS NULL AND @original_Details IS NULL)) AND (([CatagoryID] = @original_CatagoryID) OR ([CatagoryID] IS NULL AND @original_CatagoryID IS NULL)) AND [Complete] = @original_Complete AND (([CustomerID] = @original_CustomerID) OR ([CustomerID] IS NULL AND @original_CustomerID IS NULL)) AND (([GroupID] = @original_GroupID) OR ([GroupID] IS NULL AND @original_GroupID IS NULL)) AND (([AssignedToID] = @original_AssignedToID) OR ([AssignedToID] IS NULL AND @original_AssignedToID IS NULL)) AND (([CreatorID] = @original_CreatorID) OR ([CreatorID] IS NULL AND @original_CreatorID IS NULL)) AND (([Priority] = @original_Priority) OR ([Priority] IS NULL AND @original_Priority IS NULL)) AND (([DepartmentID] = @original_DepartmentID) OR ([DepartmentID] IS NULL AND @original_DepartmentID IS NULL)) AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL)) AND (([Date] = @original_Date) OR ([Date] IS NULL AND @original_Date IS NULL))"><DeleteParameters><asp:Parameter Name="original_TicketID" Type="Int32" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter Name="original_DepartmentID" Type="Int32" /><asp:Parameter Name="original_Priority" Type="String" /><asp:Parameter Name="original_CreatorID" Type="Int32" /><asp:Parameter Name="original_AssignedToID" Type="Int32" /><asp:Parameter Name="original_Date" DbType="Date" /><asp:Parameter Name="original_GroupID" Type="Int32" /><asp:Parameter Name="original_CustomerID" Type="Int32" /><asp:Parameter Name="Original_DateCompleted" DbType="Date" /><asp:Parameter Name="original_Complete" /><asp:Parameter Name="original_CatagoryID" Type="Int32" /><asp:Parameter Name="original_DueDate" /></DeleteParameters><InsertParameters><asp:Parameter Name="Complete" Type="Int32" /><asp:Parameter Name="Description" Type="String" /><asp:Parameter Name="DepartmentID" Type="Int32" /><asp:Parameter Name="Priority" Type="String" /><asp:Parameter Name="CreatorID" Type="Int32" /><asp:Parameter Name="AssignedToID" Type="Int32" /><asp:Parameter Name="Date" DbType="Date" /><asp:Parameter Name="GroupID" Type="Int32" /><asp:Parameter Name="CustomerID" Type="Int32" /><asp:Parameter Name="CatagoryID" Type="Int32" /><asp:Parameter Name="Details" Type="String" /><asp:Parameter Name="DateCompleted" DbType="Date" /></InsertParameters><SelectParameters><asp:ControlParameter ControlID="ddTicketType" Name="Complete" 
                PropertyName="SelectedValue" /></SelectParameters><UpdateParameters><asp:Parameter DbType="Date" Name="DueDate" /><asp:Parameter DbType="Date" Name="DateCompleted" /><asp:Parameter Name="Details" Type="String" /><asp:Parameter Name="CatagoryID" Type="Int32" /><asp:Parameter Name="Complete" Type="Boolean" /><asp:Parameter Name="CustomerID" Type="Int32" /><asp:Parameter Name="GroupID" Type="Int32" /><asp:Parameter Name="AssignedToID" Type="Int32" /><asp:Parameter Name="CreatorID" Type="Int32" /><asp:Parameter Name="Priority" Type="String" /><asp:Parameter Name="DepartmentID" Type="Int32" /><asp:Parameter Name="Description" Type="String" /><asp:Parameter DbType="Date" Name="Date" /><asp:Parameter Name="original_TicketID" Type="Int32" /><asp:Parameter DbType="Date" Name="original_DueDate" /><asp:Parameter DbType="Date" Name="original_DateCompleted" /><asp:Parameter Name="original_Details" Type="String" /><asp:Parameter Name="original_CatagoryID" Type="Int32" /><asp:Parameter Name="original_Complete" Type="Boolean" /><asp:Parameter Name="original_CustomerID" Type="Int32" /><asp:Parameter Name="original_GroupID" Type="Int32" /><asp:Parameter Name="original_AssignedToID" Type="Int32" /><asp:Parameter Name="original_CreatorID" Type="Int32" /><asp:Parameter Name="original_Priority" Type="String" /><asp:Parameter Name="original_DepartmentID" Type="Int32" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter DbType="Date" Name="original_Date" /></UpdateParameters></asp:SqlDataSource>


I have the following sqldatasource.  I have changed my gridview to template fields and my Delete and Update buttons are not working.  Any help would be appreciated.  Also here is one of my template fields.

<asp:TemplateField SortExpression="CreatorID"><HeaderTemplate><asp:LinkButton ID="lbCreatorID" runat="server" CausesValidation="False" CommandName="Sort" Text="Creator"></asp:LinkButton><asp:DropDownList ID="ddCreatorID" runat="server" DataSourceID="SqlDataSource6" DataTextField="CreatorName" DataValueField="CreatorID" AutoPostBack="True" OnSelectedIndexChanged="ddCreatorID_SelectedIndexChanged"></asp:DropDownList></HeaderTemplate><ItemTemplate><asp:Label ID="lblCreatorID" runat="server" Text='<%# Bind("CreatorName") %>'></asp:Label><asp:Label ID="lblCreatorIDHid" runat="server" Text='<%# Bind("CreatorID") %>' Visible="False"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("CreatorID") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:DropDownList ID="ddCreatorID" runat="server" DataSourceID="SqlDataSource6" DataTextField="CreatorName" DataValueField="CreatorID" ToolTip="Creator" SelectedValue='<%# 2 %>' /></FooterTemplate><FooterStyle Width="15px" /><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Left" /></asp:TemplateField>


How to set a SQLDataSource InsertParameter default value of type DBType=Binary

$
0
0

This is a variation on a question I asked earlier.

I have a SQLDataSource1 and a InsertParameter called AttachmentData of type "DBType=Binary".

I want to load the parameter from a Byte array called Buffer.  Dim Buffer as Byte().

this works from inside an Inserting event:

e.command.parameters("@AttachmentData").value = Buffer

But I need to do it from a prior event so I'm trying this.

SQLDataSource1.InsertParameters("AttachmentData").defaultvalue = Buffer

It gives the error:

Value of type "1-dimensional array of Byte' cannot be converted to 'String'.

What can I do?

ASP.NET modify connectionstring at runtime

$
0
0

I need to change dataset connectionstrings to point to different DBs at run time.

I've looked at a number of solutions however they all seem to be related to WinForms or web application projects or other technology slightly different than what I'm using, so I haven't figured out how apply them.

The application is like a discussion. It's a web site project based on code originally written under VS2005, and there's no budget (or personal talent!) for major changes at this time. The app is written in vb.net; I can understand answers in c#. I'm working in VS2013.

For example, the following post has lots of solutions, however, they seem to focus on web application projects, that have a project file with settings, which this web site project does not. 

https://social.msdn.microsoft.com/Forums/en-US/7483b816-be7a-4204-a4d3-cfb14b2aae26/how-to-dynamically-change-connection-string-in-generated-dataset-class?forum=adodotnetdataset

The app has three typed datasets pointing to one MDF, call it "MainDB.mdf". There are dozens of tableadapters among the three datasets.

I'm going to deploy the app it as an "alpha/demo" version. I would like to use the same code base for all users, and a separate physical version of MainDB for each user, to reduce chances that the users crash each other.

The initial demo access URL will contain query string information that I can use to connect the user with the right physical database file. I should be able to identify the database name and thus the connection string parameters from the query string information (probably using replace on a generic connection string). If necessary I could use appsettings to store fully formed connection strings, however, I would like to avoid that.

I would like to be able to change the connection strings for all the datasets at the time that the entry point pages for the app are accessed.

Changing the tableadapter connection strings at each instantiation of the tableapters would (maybe) require too much code change (at least a couple of hundred instantiations); I'dmaybe just make complete separate sites instead of doing that. That's the fall back position if I can't dynamically change the connectionstrings at runtime (or learn some other way to make this general scheme work).

Below is a sample instantiation of tableadapter (admittedly not great code, however, it works for the demo version).

Any suggestions on how to approach this would be appreciated.

Thanks!

Public Shared Sub ClearOperCntrlIfHasThisStaff( _
    varSesnID As Integer, varWrkprID As Integer)

    Dim TA As GSD_DataSetTableAdapters.OPER_CNTRLTableAdapter

    Dim DR As GSD_DataSet.OPER_CNTRLRow
    DR = DB.GetOperCntrlRowBySesnID(varSesnID)

    If IsNothing(DR) Then
        Exit Sub
    End If

    If DR.AField = varWrkprID Then
        DR.AField = -1
        TA.Update(DR)
        DR.AcceptChanges()
    End If

End Sub

How to split data and store values using case in sql server

$
0
0

Hi i have data like this

Id  Data

1 000000000000000000000000000000000000000000
2 STDSTDSTDSTDSTDSTDSTDSTD
3 000000000000
4 000000000000000000000000000000000000000000000000XXX000000000000000000000000000000000000000000000000000000XXX
5 000XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX000000000000
6 000000000000000000000000XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX000000000000000000000000000000000000000

i want to split data 

like 000 set value for 1

STD set value for 2 

and then max value from this

How to implement search in ObjectDataSource

$
0
0

Hi to all

I'm use object data source & grid view to show my data.

I set select method & select count method for implement custom paging & its work...

But I want to add search parameter to filter the result & I want to do this with custom paging.

Please help me

Thanks

Connection.close slow using OleDb

$
0
0

We're developing an n-tier application, using an Access database. We're basically finished with the application, but we're optimising some of the slower pages. Using a profiler and a timer measuring the time spent in rendering, sql and framwork parts of the application we tracked down the lackluster performance to the places where we we called connection.close()(in the try-catch-finally).

If we drop the close statement, performance is many times faster:

Using try-catch-finally and connection.close()
SQL statements: 245
SQL executiontime: 614ms
Framework execution time:11461ms
Page rendering :94ms
Total execution time:11555ms

Without connection.close()
SQL statements: 245
SQL executiontime: 559ms
Framework execution time:1447ms
Page rendering :117ms
Total execution time:1564ms

Any suggestions on why this is happening?

ODBC Connection To SQL Server Slow

$
0
0

I have a .net client application which access SQL server database from ODBC drivers 32 bit. and application is running slow due to the performance of ODBC connection. how to improve the performance of ODBC connection to SQL server.

Thanks in advance..

Error on Delete or edit

$
0
0

Please help.  Here is my code for my page.  When I do a edit or delete on the first page it works fine, but when I'm on a different page using controls at bottom of gridview it won't delete or edit.  Does anyone see why?

<%@ Page Title="" Language="VB" MasterPageFile="site.master" AutoEventWireup="false" CodeFile="Tickets5.aspx.vb" Inherits="Tickets5" %><asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" Runat="Server"></asp:Content><asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" Runat="Server"><asp:Label ID="lblTicketType" runat="server" Font-Bold="True" 
         Font-Size="Medium" ForeColor="White" 
         style="z-index: 1; left: 29px; top: 78px; position: absolute; width: 238px" 
         Text="Selecte Ticket Type to view:"></asp:Label><asp:DropDownList ID="ddTicketType" runat="server" 
         style="z-index: 1; left: 270px; top: 78px; position: absolute; height: 28px; width: 312px" 
         AutoPostBack="True" Font-Bold="True"><asp:ListItem Selected="True" Value="0">Open Tickets</asp:ListItem><asp:ListItem Value="1">Closed Tickets</asp:ListItem></asp:DropDownList><asp:Button ID="btnClear" runat="server" Text="Clear Search" Visible="False" style="z-index: 1; left: 742px; top: 78px; position: absolute" /><asp:Button ID="btnShowCompleteDate" runat="server" Text="Show Date Complete" style="z-index: 1; left: 592px; top: 78px; position: absolute" /><br /><%-- + Column ********************--%><br /><asp:GridView ID="GridView1" GridLines="None"  CellPadding = "5" 
         OnRowCommand = "GridView1_RowCommand" ShowFooter="True" runat="server" 
         AutoGenerateColumns="False" DataKeyNames="TicketID" 
         DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" 
         PageSize="12" OnPageIndexChanging="Gridview1_PageIndexChanging" 
         Font-Bold="True"><PagerStyle HorizontalAlign="Center" BackColor="#FFFF99" Font-Bold="True" Font-Names="Arial Black" Font-Size="XX-Large" /><Columns><%-- + Column ********************--%><asp:TemplateField><ItemTemplate><a href="javascript:expandcollapse('div<%# Eval("TicketID") %>', 'one');"><img id="imgdiv<%# Eval("TicketID") %>" alt="Click to show/hide Orders for Customer <%# Eval("TicketID") %>"  width="9px" border="0" src="plus.gif"/></a></ItemTemplate></asp:TemplateField><%-- Command Field ********************--%><asp:TemplateField><HeaderTemplate><br /><asp:LinkButton ID="lbSearch" runat="server" CausesValidation="False" Text="Search > "></asp:LinkButton></HeaderTemplate><ControlStyle BackColor="#FFC0C0" /><ItemTemplate><asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Select"
                            Text="Select" /><asp:Button ID="Button4" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="Edit" OnClientClick="return confirm('Edit?')" /><asp:Button ID="Button3" runat="server" CausesValidation="False" CommandName="Delete"
                            Text="Delete" OnClientClick="return confirm('Delete')" /></ItemTemplate><EditItemTemplate><asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>&nbsp;<asp:LinkButton ID="LinkButton5" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton></EditItemTemplate><%-- <FooterTemplate><asp:LinkButton ID="AddTicket" CommandName="AddTicket" runat="server" CausesValidation="False" Font-Size="X-Large">Add</asp:LinkButton></FooterTemplate>--%><HeaderStyle Wrap="False" /><ItemStyle Wrap="False" /></asp:TemplateField><%--      Complete  ***************************--%><asp:TemplateField ><HeaderTemplate><asp:CheckBox ID="cbDone1" runat="server" Checked='<%# Bind("Complete") %>' 
            Enabled="false" /><br /><br /></HeaderTemplate><ItemTemplate><asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Complete") %>' 
                    Enabled="false" /></ItemTemplate><EditItemTemplate><asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("Complete") %>' /></EditItemTemplate><ControlStyle Width="25px" /><HeaderStyle Width="25px" /><ItemStyle Width="25px" /></asp:TemplateField><%--       Open Ticket ID ***************************--%><asp:TemplateField SortExpression="TicketID"><HeaderTemplate><asp:LinkButton ID="lbOpenTicketID" runat="server" CausesValidation="False" CommandName="Edit" Text="ID"></asp:LinkButton><br /><br /></HeaderTemplate><ItemTemplate><asp:Label ID="lblItemTicketID" runat="server" Text='<%# Bind("TicketID") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:Label ID="lblEditTicketID" runat="server" Text='<%# Bind("TicketID") %>'></asp:Label></EditItemTemplate><HeaderStyle Width="100px" /><ItemStyle Width="100px" /></asp:TemplateField><%--       Date ***************************--%><asp:TemplateField SortExpression="Date"><HeaderTemplate><asp:LinkButton ID="lbDate" runat="server" CausesValidation="False" CommandName="Edit" Text="Date"></asp:LinkButton><br /><br /></HeaderTemplate><ItemTemplate><asp:Label ID="lblDate" runat="server" Text='<%# Bind("Date","{0:d}") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtDateEIT" runat="server" Text='<%# Bind("Date") %>'></asp:TextBox></EditItemTemplate><HeaderStyle HorizontalAlign="Center" Width="120px" /><ItemStyle HorizontalAlign="Left" Width="120px"/><FooterTemplate><asp:TextBox ID="txtDate" Text='<%#  DateTime.Today.ToString("MM/dd/yy") %>' runat="server" Width="60px" ToolTip="Date"></asp:TextBox></FooterTemplate><HeaderStyle  /></asp:TemplateField><%--      Description  ***************************--%><asp:TemplateField SortExpression="Description"><HeaderTemplate><asp:LinkButton ID="lbDescription" runat="server" Text="Description" CommandName="Sort" CommandArgument="Description"></asp:LinkButton><br /><asp:TextBox ID="txtDescriptionSearch" runat="server" AutoPostBack="True" OnTextChanged="txtDescriptionSearch_textchanged"></asp:TextBox></HeaderTemplate><ItemTemplate><asp:Label ID="lblDescription" runat="server" Text='<%# Bind("Description") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtDescription1" Width="450px" Text='' runat="server" ToolTip="Description"></asp:TextBox></FooterTemplate><HeaderStyle HorizontalAlign="Left" Width = "300"/><ItemStyle HorizontalAlign="Left"  Width = "300" /></asp:TemplateField><%--       Department ***************************--%><asp:TemplateField SortExpression="DepartmentID" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"><HeaderTemplate><asp:LinkButton ID="lbDepartmentID" runat="server" CausesValidation="False" CommandName="Sort" Text="Department"></asp:LinkButton><asp:DropDownList ID="ddDepartmentID" runat="server" DataSourceID="SqlDataSource3" DataTextField="Department" DataValueField="DepartmentID" AutoPostBack="True" OnSelectedIndexChanged="ddDepartmentID_SelectedIndexChanged"></asp:DropDownList><br /></HeaderTemplate><ItemTemplate><asp:Label ID="lblDepartment" runat="server" Text='<%# Bind("Department") %>'></asp:Label><%--<asp:DropDownList ID="DropDownList3" runat="server" cssClass="select" DataSourceID="SqlDataSource3" DataTextField="Department" DataValueField="DepartmentID" style="border-color: #FFFFFF; height: 22px" SelectedValue='<%# Bind("DepartmentID") %>'></asp:DropDownList>--%></ItemTemplate><EditItemTemplate><%-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DepartmentID") %>'></asp:TextBox>--%><asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3" DataTextField="Department" DataValueField="DepartmentID" SelectedValue='<%# Bind("DepartmentID") %>'></asp:DropDownList></EditItemTemplate><HeaderStyle Width="500px" /><ItemStyle Width="500px" /><FooterTemplate><%--<asp:TextBox ID="txtDepartmentID" Text='' runat="server" Width="80px"></asp:TextBox>--%><asp:DropDownList ID="ddDepartment" runat="server" DataSourceID="SqlDataSource3" DataTextField="Department" DataValueField="DepartmentID" ToolTip="Department"></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden"><ItemTemplate><asp:Label ID="lblDepartmentHid" runat="server" Text='<%# Bind("DepartmentID") %>'></asp:Label></ItemTemplate></asp:TemplateField><%--      Priority  ***************************--%><asp:TemplateField SortExpression="Priority"><HeaderTemplate><asp:LinkButton ID="lbPriority" runat="server" Text="Priority" CommandName="Sort" CommandArgument="Priority"></asp:LinkButton><br /><asp:TextBox ID="txtPrioritySearch" runat="server" AutoPostBack="True" OnTextChanged="txtPrioritySearch_textchanged" Width="50px"></asp:TextBox></HeaderTemplate><ItemTemplate><asp:Label ID="lblPriority" runat="server" Text='<%# Bind("Priority") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Priority") %>'></asp:TextBox></EditItemTemplate><ControlStyle Width="15px" /><FooterStyle Width="15px" /><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Left" Width="15px" /><ItemStyle HorizontalAlign="Right" /><FooterTemplate><asp:TextBox ID="txtPriority" Text='12' runat="server" Width="50px" ToolTip="Priority"></asp:TextBox></FooterTemplate></asp:TemplateField><%--       Creator ***************************--%><asp:TemplateField SortExpression="CreatorID"><HeaderTemplate><asp:LinkButton ID="lbCreatorID" runat="server" CausesValidation="False" CommandName="Sort" Text="Creator"></asp:LinkButton><asp:DropDownList ID="ddCreatorID" runat="server" DataSourceID="SqlDataSource6" DataTextField="CreatorName" DataValueField="CreatorID" AutoPostBack="True" OnSelectedIndexChanged="ddCreatorID_SelectedIndexChanged"></asp:DropDownList></HeaderTemplate><ItemTemplate><asp:Label ID="lblCreatorID" runat="server" Text='<%# Bind("CreatorName") %>'></asp:Label><asp:Label ID="lblCreatorIDHid" runat="server" Text='<%# Bind("CreatorID") %>' Visible="False"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("CreatorID") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:DropDownList ID="ddCreatorID" runat="server" DataSourceID="SqlDataSource6" DataTextField="CreatorName" DataValueField="CreatorID" ToolTip="Creator" SelectedValue='<%# 2 %>' /></FooterTemplate><FooterStyle Width="15px" /><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Left" /></asp:TemplateField><asp:TemplateField  HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden"><ItemTemplate><asp:Label ID="lblCreatorID1" runat="server" Text='<%# Bind("CreatorID") %>' Visible="False"></asp:Label></ItemTemplate></asp:TemplateField><%--       Assigned TO ***************************--%><asp:TemplateField HeaderText="AssignedToID" SortExpression="AssignedToID"><HeaderTemplate><asp:LinkButton ID="AssignedToID" runat="server" CausesValidation="False" CommandName="Sort" Text="Assigned To"></asp:LinkButton><br /><asp:DropDownList ID="ddAssignedToID" runat="server" DataSourceID="SqlDataSource8" DataTextField="AssignedTOName" DataValueField="AssignedTOID" AutoPostBack="True" OnSelectedIndexChanged="ddCreatorID_SelectedIndexChanged"></asp:DropDownList></HeaderTemplate><ItemTemplate><asp:Label ID="lblAssignedToID" runat="server" Text='<%# Bind("AssignedToID") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("AssignedToID") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtAssignedToID" Text='1' runat="server" Width="50px" ToolTip="Assigned To"></asp:TextBox></FooterTemplate><HeaderStyle HorizontalAlign="Center" Wrap="False" /><ItemStyle HorizontalAlign="Center" /></asp:TemplateField><%--       Group ID ***************************--%><asp:TemplateField SortExpression="GroupID"><HeaderTemplate><asp:LinkButton ID="lbGroupID" runat="server" CausesValidation="False" CommandName="Sort" Text="Group"></asp:LinkButton><br /><asp:DropDownList ID="ddGroupID" runat="server" DataSourceID="SqlDataSource4" DataTextField="GroupName" DataValueField="GroupID" AutoPostBack="True" OnSelectedIndexChanged="ddGroupID_SelectedIndexChanged"></asp:DropDownList></HeaderTemplate>            <ItemTemplate><asp:Label ID="lblGroupName" runat="server" Text='<%# Bind("GroupName") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSource4" DataTextField="GroupName" DataValueField="GroupID" SelectedValue='<%# Bind("GroupID") %>'></asp:DropDownList></EditItemTemplate><HeaderStyle HorizontalAlign="Center" Wrap="False" /><ItemStyle HorizontalAlign="Center" /><FooterTemplate><asp:DropDownList ID="ddGroupID" runat="server" DataSourceID="SqlDataSource4" DataTextField="GroupName" DataValueField="GroupID" ToolTip="Group" /></FooterTemplate><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Left" /></asp:TemplateField><asp:TemplateField HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden"><ItemTemplate><asp:Label ID="lblGroupNameHid" runat="server" Text='<%# Bind("GroupID") %>' Visible="False"></asp:Label></ItemTemplate></asp:TemplateField><%--       Customer ID ***************************--%><asp:TemplateField SortExpression="CustomerID"><HeaderTemplate><asp:LinkButton ID="lbCustomerID" runat="server" CausesValidation="False" CommandName="Sort" Text="Customer"></asp:LinkButton><asp:DropDownList ID="ddCustomerID" runat="server" DataSourceID="SqlDataSource5" DataTextField="CustomerName" DataValueField="CustomerID" AutoPostBack="True" OnSelectedIndexChanged="ddCustomerID_SelectedIndexChanged"></asp:DropDownList></HeaderTemplate>            <ItemTemplate><asp:Label ID="lblCustomerName" runat="server" Text='<%# Bind("CustomerName") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="SqlDataSource5" DataTextField="CustomerName" DataValueField="CustomerID" SelectedValue='<%# Bind("CustomerID") %>'></asp:DropDownList></EditItemTemplate><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Center" /><FooterTemplate><asp:DropDownList ID="ddCustomerID" runat="server" DataSourceID="SqlDataSource5" DataTextField="CustomerName" DataValueField="CustomerID" ToolTip="Customer" /></FooterTemplate><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Left" /></asp:TemplateField><asp:TemplateField HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden"><ItemTemplate><asp:Label ID="lblCustomerNameHid" runat="server" Text='<%# Bind("CustomerID") %>' Visible="False"></asp:Label></ItemTemplate></asp:TemplateField><%--   Date Completed ************************--%><asp:TemplateField SortExpression="DateCompleted" Visible="False"><HeaderTemplate><asp:LinkButton ID="lbDateCompleted" runat="server" CausesValidation="False" CommandName="Edit" Text="Date Completed"></asp:LinkButton><br /><br /></HeaderTemplate><ItemTemplate><asp:Label ID="lblDateCompleted" runat="server" Text='<%# Bind("DateCompleted","{0:d}") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtDateCompletedEIT" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:TextBox></EditItemTemplate><HeaderStyle HorizontalAlign="Center" Width="120px" /><ItemStyle HorizontalAlign="Left" Width="120px"/><FooterTemplate><asp:TextBox ID="txtDateCompleted" Text='<%#  DateTime.Today.ToString("MM/dd/yy") %>' runat="server" Width="60px" ToolTip="Date Completed"></asp:TextBox></FooterTemplate></asp:TemplateField></Columns><RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" Height="4px" /><SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /><PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Center" /><HeaderStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="White" /><AlternatingRowStyle BackColor="#F7F7F7" /></asp:GridView><asp:Button ID="AddTicket" runat="server" Text="Add Ticket" Font-Size="Large" style="z-index: 1; left: 1439px; top: 605px; position: absolute" ></asp:Button><asp:SqlDataSource ID="SqlDataSource3" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [DepartmentID], [Department] FROM [Departments]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource4" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [GroupID], [GroupName] FROM [Group]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource5" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [CustomerID], [CustomerName] FROM [Customers]"></asp:SqlDataSource><br /><asp:TextBox ID="txtSelectedRowDescription" runat="server" 
         style="z-index: 1; left: 122px; width:800px; position: absolute; height: 21px;" 
         Font-Size="Large" Font-Bold="True" BorderStyle="None"></asp:TextBox><br /><br /><asp:GridView ID="GridView2" runat="server" OnRowCommand = "GridView2_RowCommand" AllowPaging="True" ShowFooter="True" AllowSorting="True"   EmptyDataRowStyle-BackColor="Red" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False"  Datakeyname="TicketID" DataSourceID="SqlDataSource2" DataKeyNames="CommentID"><Columns><asp:TemplateField ShowHeader="False"><ItemTemplate><asp:LinkButton ID="LinkButton6" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>&nbsp;<asp:LinkButton ID="LinkButton7" runat="server" CausesValidation="False" CommandName="Select" Text="Select"></asp:LinkButton>&nbsp;<asp:LinkButton ID="LinkButton8" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton></ItemTemplate><EditItemTemplate><asp:LinkButton ID="LinkButton9" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>&nbsp;<asp:LinkButton ID="LinkButton10" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton></EditItemTemplate><FooterTemplate><asp:LinkButton ID="AddComment" CommandName="AddComment" runat="server" Font-Size="X-Large">Add</asp:LinkButton></FooterTemplate><HeaderStyle Wrap="False" /><ItemStyle Wrap="False" /></asp:TemplateField><asp:BoundField DataField="CommentID" HeaderText="ID" SortExpression="CommentID" ReadOnly="True" /><asp:TemplateField HeaderText="Date" SortExpression="Date" ItemStyle-Width="15px" ItemStyle-ForeColor="Black"><EditItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Date") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("Date") %>' Font-Bold="True"></asp:Label></ItemTemplate><FooterTemplate><asp:TextBox ID="txtDate1" Text='' runat="server" ToolTip="Date" Width="25px"></asp:TextBox></FooterTemplate><ItemStyle Width="15px"></ItemStyle></asp:TemplateField><asp:TemplateField HeaderText="Description" SortExpression="Description" ItemStyle-ForeColor="Black" HeaderStyle-HorizontalAlign="Left"><EditItemTemplate><asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>' Font-Bold="True"></asp:Label></ItemTemplate><HeaderStyle Width="700px" /><Itemstyle Width="700px" HorizontalAlign="Left" /><FooterTemplate><asp:TextBox ID="txtDescription1" Text='' runat="server" ToolTip="Description" Width="700px"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Mileage" SortExpression="Mileage" ItemStyle-ForeColor="Black" ItemStyle-Width="25px"><ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("Mileage") %>' Font-Bold="True"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Mileage") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtMileage1" Text='' runat="server" ToolTip="Mileage" Width="50px"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Start Time" SortExpression="StartTime" ItemStyle-ForeColor="Black"><ItemTemplate><asp:Label ID="Label5" runat="server" Text='<%# Bind("StartTime") %>' Font-Bold="True"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("StartTime") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtStartTime1" Text='' runat="server" ToolTip="Start Time" Width="60px"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="End Time" SortExpression="EndTime" ItemStyle-ForeColor="Black"><ItemTemplate><asp:Label ID="Label6" runat="server" Text='<%# Bind("EndTime") %>' Font-Bold="True"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("EndTime") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtEndTime1" Text='' runat="server" Width="60px"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Equipment Cost" SortExpression="EquipmentCost" ItemStyle-ForeColor="Black"><ItemTemplate><asp:Label ID="Label7" runat="server" Text='<%# Bind("EquipmentCost") %>' Font-Bold="True"></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("EquipmentCost") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtEquipmentCost1" Text='' runat="server" Width="85px"></asp:TextBox></FooterTemplate></asp:TemplateField></Columns><EmptyDataRowStyle BackColor="Red"></EmptyDataRowStyle></asp:GridView><%-- Command Field ********************--%>            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT CommentID, Date, Description, Mileage, StartTime, EndTime, EquipmentCost, TicketID FROM TicketComments WHERE (TicketID = @TicketID) OR (CommentID = 1)" 
    ConflictDetection="CompareAllValues" 
    DeleteCommand="DELETE FROM [TicketComments] WHERE [CommentID] = @original_CommentID AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL)) AND (([StartTime] = @original_StartTime) OR ([StartTime] IS NULL AND @original_StartTime IS NULL)) AND (([EndTime] = @original_EndTime) OR ([EndTime] IS NULL AND @original_EndTime IS NULL)) AND (([Mileage] = @original_Mileage) OR ([Mileage] IS NULL AND @original_Mileage IS NULL)) AND (([Date] = @original_Date) OR ([Date] IS NULL AND @original_Date IS NULL)) AND (([EquipmentCost] = @original_EquipmentCost) OR ([EquipmentCost] IS NULL AND @original_EquipmentCost IS NULL)) AND (([TicketID] = @original_TicketID) OR ([TicketID] IS NULL AND @original_TicketID IS NULL))" 
    InsertCommand="INSERT INTO [TicketComments] ([Description], [StartTime], [EndTime], [Mileage], [Date], [EquipmentCost], [TicketID]) VALUES (@Description, @StartTime, @EndTime, @Mileage, @Date, @EquipmentCost, @TicketID)" UpdateCommand="UPDATE [TicketComments] SET [Description] = @Description, [StartTime] = @StartTime, [EndTime] = @EndTime, [Mileage] = @Mileage, [Date] = @Date, [EquipmentCost] = @EquipmentCost, [TicketID] = @TicketID WHERE [CommentID] = @original_CommentID AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL)) AND (([StartTime] = @original_StartTime) OR ([StartTime] IS NULL AND @original_StartTime IS NULL)) AND (([EndTime] = @original_EndTime) OR ([EndTime] IS NULL AND @original_EndTime IS NULL)) AND (([Mileage] = @original_Mileage) OR ([Mileage] IS NULL AND @original_Mileage IS NULL)) AND (([Date] = @original_Date) OR ([Date] IS NULL AND @original_Date IS NULL)) AND (([EquipmentCost] = @original_EquipmentCost) OR ([EquipmentCost] IS NULL AND @original_EquipmentCost IS NULL)) AND (([TicketID] = @original_TicketID) OR ([TicketID] IS NULL AND @original_TicketID IS NULL))"><DeleteParameters><asp:Parameter Name="original_CommentID" Type="Int32" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter Name="original_StartTime" Type="String" /><asp:Parameter Name="original_EndTime" Type="String" /><asp:Parameter Name="original_Mileage" Type="String" /><asp:Parameter Name="original_Date" Type="String" /><asp:Parameter Name="original_EquipmentCost" Type="String" /><asp:Parameter Name="original_TicketID" Type="Int32" /></DeleteParameters><InsertParameters><asp:Parameter Name="Description" Type="String" /><asp:Parameter Name="StartTime" Type="String" /><asp:Parameter Name="EndTime" Type="String" /><asp:Parameter Name="Mileage" Type="String" /><asp:Parameter Name="Date" Type="String" /><asp:Parameter Name="EquipmentCost" Type="String" /><asp:Parameter Name="TicketID" Type="Int32" /></InsertParameters><SelectParameters><asp:ControlParameter ControlID="GridView1" Name="TicketID" PropertyName="SelectedValue" Type="Int32" /></SelectParameters><UpdateParameters><asp:Parameter Name="CommentID" Type="Int32" /><asp:Parameter Name="Description" Type="String" /><asp:Parameter Name="StartTime" Type="String" /><asp:Parameter Name="EndTime" Type="String" /><asp:Parameter Name="Mileage" Type="String" /><asp:Parameter Name="Date" Type="String" /><asp:Parameter Name="EquipmentCost" Type="String" /><asp:Parameter Name="TicketID" Type="Int32" /><asp:Parameter Name="original_CommentID" Type="Int32" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter Name="original_StartTime" Type="String" /><asp:Parameter Name="original_EndTime" Type="String" /><asp:Parameter Name="original_Mileage" Type="String" /><asp:Parameter Name="original_Date" Type="String" /><asp:Parameter Name="original_EquipmentCost" Type="String" /><asp:Parameter Name="original_TicketID" Type="Int32" /></UpdateParameters></asp:SqlDataSource><%--' AND (Description = @original_Description OR Description IS NULL AND @original_Description IS NULL) AND (DepartmentID = @original_DepartmentID OR DepartmentID IS NULL AND @original_DepartmentID IS NULL) AND (Priority = @original_Priority OR Priority IS NULL AND @original_Priority IS NULL) AND (CreatorID = @original_CreatorID OR CreatorID IS NULL AND @original_CreatorID IS NULL) AND (AssignedToID = @original_AssignedToID OR AssignedToID IS NULL AND @original_AssignedToID IS NULL) AND (Date = @original_Date OR Date IS NULL AND @original_Date IS NULL) AND (GroupID = @original_GroupID OR GroupID IS NULL AND @original_GroupID IS NULL) AND (CustomerID = @original_CustomerID OR CustomerID IS NULL AND @original_CustomerID IS NULL) AND (DateCompleted = @original_DateCompleted OR DateCompleted IS NULL AND @original_DateCompleted IS NULL) AND (Complete = @original_Complete OR Complete IS NULL AND @original_Complete IS NULL) AND (CatagoryID = @original_CatagoryID OR CatagoryID IS NULL AND @original_CatagoryID IS NULL) AND (DueDate = @original_DueDate OR DueDate IS NULL AND @original_DueDate IS NULL)"         --%><%-- ****************************************************************--%><asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" 
        SelectCommand="SELECT TicketsDetail.Complete, TicketsDetail.TicketID, TicketsDetail.Description, TicketsDetail.DepartmentID, TicketsDetail.Priority, TicketsDetail.CreatorID, TicketsDetail.AssignedToID, TicketsDetail.Date, Departments.Department, TicketsDetail.GroupID, TicketsDetail.CustomerID, TicketsDetail.DateCompleted, TicketsDetail.Details, TicketsDetail.CatagoryID, Customers.CustomerName, [Group].GroupName, Creator.CreatorName, TicketsDetail.DueDate FROM TicketsDetail INNER JOIN Departments ON TicketsDetail.DepartmentID = Departments.DepartmentID INNER JOIN Customers ON TicketsDetail.CustomerID = Customers.CustomerID INNER JOIN [Group] ON TicketsDetail.GroupID = [Group].GroupID INNER JOIN Creator ON TicketsDetail.CreatorID = Creator.CreatorID WHERE (TicketsDetail.Complete = @Complete)"
        ConflictDetection="CompareAllValues" 

             DeleteCommand="DELETE FROM [TicketsDetail] WHERE [TicketID] = @original_TicketID AND (([Date] = @original_Date) OR ([Date] IS NULL AND @original_Date IS NULL)) AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL)) AND (([DepartmentID] = @original_DepartmentID) OR ([DepartmentID] IS NULL AND @original_DepartmentID IS NULL)) AND (([Priority] = @original_Priority) OR ([Priority] IS NULL AND @original_Priority IS NULL)) AND (([CreatorID] = @original_CreatorID) OR ([CreatorID] IS NULL AND @original_CreatorID IS NULL)) AND (([AssignedToID] = @original_AssignedToID) OR ([AssignedToID] IS NULL AND @original_AssignedToID IS NULL)) AND (([GroupID] = @original_GroupID) OR ([GroupID] IS NULL AND @original_GroupID IS NULL)) AND (([CustomerID] = @original_CustomerID) OR ([CustomerID] IS NULL AND @original_CustomerID IS NULL)) AND [Complete] = @original_Complete AND (([CatagoryID] = @original_CatagoryID) OR ([CatagoryID] IS NULL AND @original_CatagoryID IS NULL)) AND (([Details] = @original_Details) OR ([Details] IS NULL AND @original_Details IS NULL)) AND (([DateCompleted] = @original_DateCompleted) OR ([DateCompleted] IS NULL AND @original_DateCompleted IS NULL)) AND (([DueDate] = @original_DueDate) OR ([DueDate] IS NULL AND @original_DueDate IS NULL))" 
        InsertCommand="INSERT INTO [TicketsDetail] ([Date], [Description], [DepartmentID], [Priority], [CreatorID], [AssignedToID], [GroupID], [CustomerID], [Complete], [CatagoryID], [Details], [DateCompleted], [DueDate]) VALUES (@Date, @Description, @DepartmentID, @Priority, @CreatorID, @AssignedToID, @GroupID, @CustomerID, @Complete, @CatagoryID, @Details, @DateCompleted, @DueDate)" 
        OldValuesParameterFormatString="original_{0}" 
         UpdateCommand="UPDATE [TicketsDetail] SET [Date] = @Date, [Description] = @Description, [DepartmentID] = @DepartmentID, [Priority] = @Priority, [CreatorID] = @CreatorID, [AssignedToID] = @AssignedToID, [GroupID] = @GroupID, [CustomerID] = @CustomerID, [Complete] = @Complete, [CatagoryID] = @CatagoryID, [Details] = @Details, [DateCompleted] = @DateCompleted, [DueDate] = @DueDate WHERE [TicketID] = @original_TicketID AND (([Date] = @original_Date) OR ([Date] IS NULL AND @original_Date IS NULL)) AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL)) AND (([DepartmentID] = @original_DepartmentID) OR ([DepartmentID] IS NULL AND @original_DepartmentID IS NULL)) AND (([Priority] = @original_Priority) OR ([Priority] IS NULL AND @original_Priority IS NULL)) AND (([CreatorID] = @original_CreatorID) OR ([CreatorID] IS NULL AND @original_CreatorID IS NULL)) AND (([AssignedToID] = @original_AssignedToID) OR ([AssignedToID] IS NULL AND @original_AssignedToID IS NULL)) AND (([GroupID] = @original_GroupID) OR ([GroupID] IS NULL AND @original_GroupID IS NULL)) AND (([CustomerID] = @original_CustomerID) OR ([CustomerID] IS NULL AND @original_CustomerID IS NULL)) AND [Complete] = @original_Complete AND (([CatagoryID] = @original_CatagoryID) OR ([CatagoryID] IS NULL AND @original_CatagoryID IS NULL)) AND (([Details] = @original_Details) OR ([Details] IS NULL AND @original_Details IS NULL)) AND (([DateCompleted] = @original_DateCompleted) OR ([DateCompleted] IS NULL AND @original_DateCompleted IS NULL)) AND (([DueDate] = @original_DueDate) OR ([DueDate] IS NULL AND @original_DueDate IS NULL))"><DeleteParameters><asp:Parameter Name="original_TicketID" Type="Int32" /><asp:Parameter DbType="Date" Name="original_Date" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter Name="original_DepartmentID" Type="Int32" /><asp:Parameter Name="original_Priority" Type="String" /><asp:Parameter Name="original_CreatorID" Type="Int32" /><asp:Parameter Name="original_AssignedToID" Type="Int32" /><asp:Parameter Name="original_GroupID" Type="Int32" /><asp:Parameter Name="original_CustomerID" Type="Int32" /><asp:Parameter Name="original_Complete" Type="Boolean" /><asp:Parameter Name="original_CatagoryID" Type="Int32" /><asp:Parameter Name="original_Details" Type="String" /><asp:Parameter DbType="Date" Name="original_DateCompleted" /><asp:Parameter DbType="Date" Name="original_DueDate" /></DeleteParameters><InsertParameters><asp:Parameter DbType="Date" Name="Date" /><asp:Parameter Name="Description" Type="String" /><asp:Parameter Name="DepartmentID" Type="Int32" /><asp:Parameter Name="Priority" Type="String" /><asp:Parameter Name="CreatorID" Type="Int32" /><asp:Parameter Name="AssignedToID" Type="Int32" /><asp:Parameter Name="GroupID" Type="Int32" /><asp:Parameter Name="CustomerID" Type="Int32" /><asp:Parameter Name="Complete" Type="Boolean" /><asp:Parameter Name="CatagoryID" Type="Int32" /><asp:Parameter Name="Details" Type="String" /><asp:Parameter DbType="Date" Name="DateCompleted" /><asp:Parameter DbType="Date" Name="DueDate" /></InsertParameters><SelectParameters><asp:ControlParameter ControlID="ddTicketType" Name="Complete" 
                          PropertyName="SelectedValue" /></SelectParameters><UpdateParameters><asp:Parameter DbType="Date" Name="Date" /><asp:Parameter Name="Description" Type="String" /><asp:Parameter Name="DepartmentID" Type="Int32" /><asp:Parameter Name="Priority" Type="String" /><asp:Parameter Name="CreatorID" Type="Int32" /><asp:Parameter Name="AssignedToID" Type="Int32" /><asp:Parameter Name="GroupID" Type="Int32" /><asp:Parameter Name="CustomerID" Type="Int32" /><asp:Parameter Name="Complete" Type="Boolean" /><asp:Parameter Name="CatagoryID" Type="Int32" /><asp:Parameter Name="Details" Type="String" /><asp:Parameter DbType="Date" Name="DateCompleted" /><asp:Parameter DbType="Date" Name="DueDate" /><asp:Parameter Name="original_TicketID" Type="Int32" /><asp:Parameter DbType="Date" Name="original_Date" /><asp:Parameter Name="original_Description" Type="String" /><asp:Parameter Name="original_DepartmentID" Type="Int32" /><asp:Parameter Name="original_Priority" Type="String" /><asp:Parameter Name="original_CreatorID" Type="Int32" /><asp:Parameter Name="original_AssignedToID" Type="Int32" /><asp:Parameter Name="original_GroupID" Type="Int32" /><asp:Parameter Name="original_CustomerID" Type="Int32" /><asp:Parameter Name="original_Complete" Type="Boolean" /><asp:Parameter Name="original_CatagoryID" Type="Int32" /><asp:Parameter Name="original_Details" Type="String" /><asp:Parameter DbType="Date" Name="original_DateCompleted" /><asp:Parameter DbType="Date" Name="original_DueDate" /></UpdateParameters></asp:SqlDataSource><%--*****************************************************************--%><asp:SqlDataSource ID="SqlDataSource7" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [DepartmentID], [Department] FROM [Departments]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource9" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [GroupID], [GroupName] FROM [Group]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource10" runat="server"  ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" SelectCommand="SELECT [CustomerID], [CustomerName] FROM [Customers]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource6" runat="server" 
         ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" 
         SelectCommand="SELECT [CreatorID], [CreatorName] FROM [Creator]"></asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource8" runat="server" 
         ConnectionString="<%$ ConnectionStrings:ITHelpCS %>" 
         SelectCommand="SELECT [TechID], [TechName] FROM [Techs]"></asp:SqlDataSource></asp:Content>


LINQ Select field if not null.

$
0
0

Hello

Trying to select fields, combine it and load to my DropDownList.

But getting empty value if any fields is null of fields which trying to combine.

var useradress = from p in db.UserAdresses.TakeWhile(p => p.PostalCode != null)
.Where(p => p.UserID == guid)
.Select(p => new { AdressID = p.AdressID,
DisplayText = p.AdressName + " " +
p.OtherInformation + " " +
p.City + " " +
p.District + " " +
p.Part + " " +
p.ContactName + " " +
p.ContactSurName + " " +
p.PostalCode }) select p; DropDownListDeliveryAdress.DataSource = useradress; DropDownListDeliveryAdress.DataTextField = "DisplayText"; DropDownListDeliveryAdress.DataValueField = "AdressID";

How can I firstly check value and then select with LINQ?

Thanks in advance

How to start reading Table or Query from a specific record onwards?

$
0
0

I have a requirement to read an SQL Table or Query STARTING from a specified record (MS Access 2010).

This record could be identified by one unique field within it, not by record number.

Let say we have several records like this:

3054    Part xyz     01

3168    Part abc    02

2089    Part dfg    02

2765    Part ert     03

2945    Part yui     04

3512    Part asd    04

The only unique identifier is the part number which would be passed to my procedure.  So I would like to select all the parts starting from 2089 on, for example.   I cannot SELECT PartNumber>=2089 because I would get 3054 and 3168, which is not the requirement.

Help most appreciated.

SqlDataReader error

$
0
0

I get  a  'System.Data.SqlClient.SqlConnection' does not contain a definition for 'ExecuteReader' and no extension method 'ExecuteReader' compilation error , it is pointing to executeReader command :

string qsho = Request.QueryString["sho"];
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM  emailpages where item ='" + qsho + "'", con);

DataTable dt = new DataTable();
da.Fill(dt);
showform.DataSource = dt;
showform.DataBind();
/// datareader to get headr and item names
SqlDataReader rdr = con.ExecuteReader();

rdr.Read();
string rItem;
rItem = rdr["item"];

...then later i will use that item field to display on a few areas of the page i need

thanx for help
Chumley

VS208 3.5 RDLC and DataSets

$
0
0

I am using and SQL Server 2000 and accessing it with C# in VS2008 v3.5. My application is an asp.net web app. I have created a report, Report1.rdlc and have it called onto a standard report viewer attached to a web page. The report works just fine and it displays all the information in the table. The initial report was created using the report wizard. I want to now create the same report and only grab a single record by passing the DataSet/TableAdapter a reference number that is the unique key to each column. I have done 2 things, firstly I created a stored procedure in the DB that wants the RefNo passed to it to retrieve the applicable data.  I also have created another report similar to the first using the report wizard but instead of pointing to a table, I use a simple SQL query "Select * from tblOrders where RefNo = @RefNo

How do I pass the variable RefNo to either the SP or to the query so I can selectively pull data and display it on the RDLC report when the page opens up? The value of RefNo will be passed in the querystring calling the web page.  I have captured the value, just do not know how to get it to the query or SP.  The  I have searched the web a lot over the last several days and am unable to find a solution and I have been grunting through this for several more days.  Any assistance would be appreciated even a link to a very good example that I can tailor for my own use.

Many Thanks in Advance

SqlDataSource and SQL Namespace

$
0
0

I'm trying to create a simple application that connects to a SQL database. The database implements some namespaces, so the tables are named like:

HR.Employees

When I configure the sqldatasource, it sees the database and all the tables but it does not include the namespace part of the table name in the canned query. I know that I can rewrite the query but I'm teaching new ASP students so I would like to keep it as simple as possible. Anyone know a way around the namespace issue?

This is the typical query that the sqldatasource configure creates:

Select * from [Employees]

It fails and says there is no such object as Employees. I fix it by changing it to [HR].[Employees] but that removes the automated part of query building. My students will get to building manual queries later.

Viewing all 956 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>