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


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

Table Adapter generates bad SQL under load

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :Sql Server
 
I have an application (ASP.NET 2.0/SQL Server 2005) which makes heavy use of table adapters for pulling records from SQL. Under heavy load, we get a lot of SQL Server Timeout errors. We have run a trace on SQL Server and it shows that several of the SQL statements being passed into SQL Server, from the Table Adapters, have bad SQL. For example, here is the SQL in one of the table adapters SELECT    HomeMsgID, messageName, messageHTML, messageText, populationID FROM        MyUCR_HomeMessages WHERE    (populationID IN                           (SELECT    populationID                             FROM          MyUCR_Population_CPID AS MyUCR_Population_CPID_1                             WHERE      (CPID = @CPID))) AND (isVisible = 1) AND (showDate <= @showDate) AND (removeDate >= @removeDate) I call it with the following: DateTime showDate = DateTime.Today; DateTime removeDate = DateTime.Today; myUCR_HomePageMsgsTableAdapters.MyUCR_HomeMessagesTableAdapter ta = new myUCR_HomePageMsgsTableAdapters.MyUCR_HomeMessagesTableAdapter(); myUCR_HomePageMsgs.MyUCR_HomeMessagesDataTable dt = new myUCR_HomePageMsgs.MyUCR_HomeMessagesDataTable(); ta.FillByCPID(dt, showDate, removeDate, CPID); What the SQL trace shows, when it fails, is this (notice the extra single quotes around the showDate, removeDate parameters): E000 exec sp_executesql N'SELECT    HomeMsgID, messageN


View Complete Post


More Related Resource Links

How to use OPENXML to load XML data into existing SQL Table?

  
I am a newbie to OPENXML. But I am trying to load a .XML file into a SQL table that I created for this. I do not receive any errors with this code, but it doesn't insert any records either. This is the table I created in 2008 SQL Server: CREATE TABLE HOMEROOM( HOMEROOM_TEACHER INT, HOMEROOM_NUMBER INT, ENTITY_ID INT) And this is the T-SQL code I am trying to execute: DECLARE @idoc int DECLARE @xmlDocument varchar(MAX) DECLARE @Status INT SET @xmlDocument =' <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> <s:Schema id="RowsetSchema"> <s:ElementType name="row" content="eltOnly"> <s:AttributeType name="c0" rs:name="HOMEROOM-TEACHER" rs:number="1" rs:nullable="true"> <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true" /> </s:AttributeType> <s:AttributeType name="c1" rs:name="HOMEROOM-NUMBER" rs:number="2"> <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="10" rs:maybenull="false" /> </s:AttributeType> <s:Attri

My repeating table did not open/load correctly

  
In my browser-enabled form I am using a webservice to get data from one look up table in my database. The table consists of two columns (ProdId and ProdDescription). In order to allow the user to select more than one products, I bind  this data to a repeating table where the productId column converted from a check box to a checkbox instead. So every row of this repeating table have a checkbox in the first column so the user can make selection and a textbox in the second column to list the Product Description. When the user open/load the existing form where multiple selection was made to the repeating table none of the checkboxs were checked. I have no idea how to go about to fix this issue and i can use some help. So far i have not use any codes for my form so i would like to stay codeless and using rules instead. Thank you in advance.

How to load a new table with the value of a variable from SSIS package?

  
Hi, i have two variables in a SSIS package Var1 and Var2. Both of these variables have values. is there any way i can put the values of these two variables in a new table? e.g In New table col1 having value of Var1 and col2 having value of Var2. Thanks

Capture the xml filename and load in a table

  
Hey I am having folder which contains multiple xml files.Now I need to read the xml file name and write in a table. I follwed the steps which are in the following link. http://www.sqlservercentral.com/articles/SSIS/67871/ But I am getting data as well as. I need only the file name to be written in a table.

how to load dates in a table in a range

  
Hi i have a table DATEDESC with columns [FullDate] [DateName] [YearName] [MonthName] [DayOfTheWeek] [YearNumber] [MonthNumber] [WeekNumber] [DayNumber] SAMPLE DATA OUTPUT FULL_DATE DATE YEARNAME MONTH_NAME DAY_NAME YEAR MONTH_NUMBER WEEK_WITHIN_THE_MONTH WEEK_WITHIN_THE_YEAR DAY_NUMBER 2010-09-09 24:31.9 2010-09-09 NOT LEAP YEAR September Thursday 2010 9 2 37 9   I need to load a series of dates into this tale by giving a start and and end dates range. Lets say i need to load 10yrs of date's data into this column, i need to load all the dates into this table and get those respective column. The query i had to populate the sample data was with the current date. But i am not sure how to do this for a bunch of data when it is in a range. SELECT GETDATE() AS FULL_DATE, Convert(varchar(10), getdate(),110) as DATE_NAME, CASE (YEAR(GETDATE()))%4 WHEN 0 THEN 'LEAP YEAR'ELSE 'NOT LEAP YEAR' END AS [YEAR_NAME], DATENAME(MONTH,GETDATE()) AS [MONTH_NAME], DATENAME("DW",GETDATE()) AS [DAY_OF_THE_WEEK], DATENAME(YEAR,GETDATE()) AS [YEAR_NUMBER], MONTH(GETDATE()) AS MONTH_NUMBER, DATEPART(DAY,GETDATE() -1)/7+1 AS [WEEK_WITHIN_MONTH], DATENAME("WEEK",GETDATE()) AS [WEEK_WITHIN_YEAR], DAY(GETDATE()) AS  DAY_NUMBER So, could you please help me in build this query. Thank you.

Dynamically fill query parameters in a table adapter ?

  
SO I have created an object data source on a page from a table adapter using the various Wizards in Visual Studio.Its meant to query a diary Database by a DateTime parameter called diaryDate. I want to query from a date Now to the next 14 days ahead.I want to display the entries in a Grid View when the page loads.So I'm a bit stuck now as to how to set the two query parameters date1 and date2. I want to set date1 = now() and date2 = now() + 14 days.How do I set those parameters when the page loads ?Should I have used the adapter Wizard approach of do I have to write all the code in the code behind page ??This is my datasource code'<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GET_nextTwoWeeks" TypeName="query_getNextTwoWeeksTableAdapters.diaryDatesTableAdapter"> <SelectParameters> <asp:FormParameter DefaultValue="" FormField="date1" Name="date1" Type="DateTime" /> <asp:FormParameter DefaultValue="" FormField="date2" Name="date2" Type="DateTime" /> </SelectParameters> <InsertParameters>

dataset table adapter commands

  

hi

how i can disable generation of insert update delete select commands in tableadapter or how i can

remove all of these commands in dataset?

 

tank u in advance


Variable value within SQL Server table Configuration is not being updated within load of DTSX packag

  

Hi,

I am probably missing something obvious here; -
I have created a package with a variable named; - ServerName and a value of 'KIERAN-PC'
I exported this variable as an SSIS configuration within a SQL Server table

I noticed the following record appeared within the SQL Server configuration table.

 

stored procedure or table adapter commands

  

hi friends

in my windows application i used a dataset and populated it with tables by dragging tables from server explorer, and for each table's table adapter i added four stored procedures that i have created in sql server while dataset generator generates insert, update , select , delete commands for each table adapter. i want to know whick one is better, using stored procedure or using dataset generated commands?

tanks in advance

 


isdbnull() table adapter

  

Hi, was hoping someone could help.  I have a sqltableadapter with a select query, and am trying to popluate textboxes from the data retrieved.  All is well until  I come to a null value.   I've tried to check for isdbnull, in an if statement. 


' usr is defined earlier

Dim strfirstname As String = ""

Dim usrinfo As New sqlTableAdapters.UserInfoTableAdapter

                Dim mydatatable As sql.UserInfoDataTable = Nothing


                mydatatable = usrinfo.GetDataByUserID(usr)


                If Not IsDBNull(mydatatable(0).FirstName) Then


                    strfirstname = mydatatable(0).FirstName
                    Label1.Text = strfirstname
                End If      ................

(goes on for more columns)


However, the page throws an error when it gets to a column with a null value:


Line 2068: get { Line 2069: try { Line 2070: return ((string)(this[this.tableUserInfo.FirstNameColumn])); Line 2071: } Line 2072: catch (global::System.InvalidCastException e) {


Thanks!


SSIS - load table from source text file with multiple record lengths

  

I have a text file that has mulitple records lengths that I need to load into a table.  The file has multiple record types and each record type detemines the length of the record.  Let me try to explain...the file has a balance line 1, multiple detail records, balance line 2, and a trailer record.

The first record is a balance line 1, which has a record length of 144.

Detail records with a record type of inv or crd, will have a record length of 147.  The remaining record types will have a length of 144.

The second to the last record is balance line 2, which has a a record length of 156.

And the trailer record, which has a record length of 162.

Here is a portion of my source file.  I have made each line bold where you can see the rec type.  The record starting with 9999 is the trailer.

077700001BL100000002010100120101008BALANCE FORWARD 0000000000000000001081175D0000000000{0000000000{0000000000{000001081175D00 0000000000{

077701000INV01953172010100120101008GROCERY - DRY 0000000000000000000073504I0000016678K0000000852G0000000000{000000057679D011N 0000093201E010

07779008099000000002010100820101008KC CASH REC. 0000000000000000001081175M0000000000{0000000000{0000000000{000001081175M00 00000000

Could not load an entity when table is existing

  

Need help on this. I'm quite new to NHibernate.

I always get this error when the table is existing in the database:

could not load an entity: 
[Star.CNPL_BusinessObjects.Entities.CNPL.CNPL_AgencyProduct#48][SQL: SELECT cnpl_agenc0_.Id as Id48_0_, cnpl_agenc0_.AgencyID as AgencyID48_0_, cnpl_agenc0_.ProductID as ProductID48_0_, cnpl_agenc0_.CreatedDate as CreatedD4_48_0_, cnpl_agenc0_.CreatedBy as CreatedBy48_0_, cnpl_agenc0_.UpdatedDate as UpdatedD6_48_0_, cnpl_agenc0_.UpdatedBy as UpdatedBy48_0_ FROM CNPL_AgencyProduct cnpl_agenc0_ WHERE cnpl_agenc0_.Id=?]"


The inner exception of the error is this:

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) 
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) 
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 
   at System.Data.SqlClient.SqlDataReader.get_MetaData() 
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader

Load multiple record length text file into table using SSIS

  

I have a text file that has mulitple records lengths that I need to load into a table.  The file has multiple record types and each record type detemines the length of the record.  Let me try to explain...the file has a balance line 1, multiple detail records, balance line 2, and a trailer record.

The first record is a balance line 1, which has a record length of 144.

Detail records with a record type of inv or crd, will have a record length of 147.  The remaining record types will have a length of 144.

The second to the last record is balance line 2, which has a a record length of 156.

And the trailer record, which has a record length of 162.

Here is a portion of my source file.  I have made each line bold where you can see the rec type.  The record starting with 9999 is the trailer.

077700001BL100000002010100120101008BALANCE FORWARD 0000000000000000001081175D0000000000{0000000000{0000000000{000001081175D00 0000000000{

077701000INV01953172010100120101008GROCERY - DRY 0000000000000000000073504I0000016678K0000000852G0000000000{000000057679D011N 0000093201E010

07779008099000000002010100820101008KC CASH REC. 0000000000000000001081175M0000000000{0000000000{0000000000{000001081175M00 00000000

Need to mass load dated files from .txt to sql table - what is the best way?

  

Hi

I have around 500 files which are named file_27072009.txt, file_28072009.txt, file_28072009.txt etc and I need to load them all into a table. What is the easiest way to pick up each of these files in turn and load them into the sql table?

I have access to SISS or sql server mgt studio but am not an expert in either.

Any help would be much appreciated so I am not having to manually open and merge all the files into one before loading.

Thanks so much

Kirsten


Adding exception table to incremental Load with SSIS Lookup task and conditional split

  

Hello,

I have built an incremental load ETL Process to load some flat files with an SSIS Lookup and Conditional Split. I only have one path in the conditional split and that is for New Records.

I have two questions:

1.       For the new records path, I have to check to see if a record exists and I don’t have a single key that is unique, therefore, I have to use a multiple keys to make the record unique.

 

Below is what I have put in the conditional transformation editor for my first output condition:

 

how to load dimension table by using dimension processing in ssis

  
how to load dimension table into cube by using dimension proccesing destination in ssis

Using Table Adapter in Visual Studio to retrieve data

  

Hi, I have a profile of member to be displayed. I am using a dataset with all the data table adapter to retrieve the information from database. 

I have a memContact method which has NRIC and Number as a composition primary key. Thus, automatically, the table adapter has created a method called FindByICNum () for me. However, when I do the search to display the contents, i will only need to search by memberic instead. 

Is there anyway to change the table adapter query? 


ConfigurationFilter ConfiguredValue PackagePath ConfiguredValueType
Categories: 
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