.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

Problem insert POCO to Velocity Cache

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :ASP.Net


I want to put POCO object to Velocity cache. How can I serializable ICollection to Velocity cache, or exclude ICollection from serialization?

I got this exception

Type 'System.Collections.Generic.ICollection`1[Model.Collection]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.



View Complete Post

More Related Resource Links

Nested listview fk-problem with insert



My problem is this, i have a nested listview that works fine but if i need to do an insert and the nested listview dont have retrived any values (that is no posts created) i cant get hold of the fk that i need. If i put a hiddenfield in the parents listview with the fk how can i find it in codebehind when i do an insert? 



ASP.NET Cache Problem ??

I'm having a problem with an asp.net 3.0 application using a gridview to display data.  The problem seems to be that despite a brand new .selectCommand being sent to the sqlDataSource, the gridview starts displaying data from *someone else's* query.  For example, user A is logged in and will be working fine until a few page submissions later when the gridview data starts suddenly showing information that belongs to another user.  This is my first asp.net application, though I've been working with classic asp and ADO for years so I'm used to sending a SQL string and getting back the results from that string.  Apparently there is a complex caching system which is interferring which I do not at all understand so at this point I just want to stop the server from caching any data whatsoever.  Is this possible? Any and all help will be much appreciated!!

Insert into and Store procedure problem

Hello I am trying to create store procedure wich will insert data in temp table CREATE PROCEDURE GetDataForUpdate AS if exists(select * from sys.objects where name='GetDataForUpdate_temp_tb') begin DROP TABLE GetDataForUpdate_temp_tb end go WITH cte as (select Sp.[Item No_], Sp.[Starting Date], It.[No_], It.[Manufacturer Code], It.[Description], Sp.[Unit Price], row_number () over (partition by Sp.[Item No_] order by Sp.[Starting Date] desc) as rn from dbo.[Main-db$Sales Price] AS Sp JOIN dbo.[Main-db$Item] AS It ON Sp.[Item No_] = It.[No_] WHERE Sp.[Sales Code]='RETAIL' AND Sp.[Item No_] LIKE 'I%' ), cte2 as ( SELECT [Item No_],SUM(ISNULL(Quantity, 0)) AS Qty FROM [Main-db$Item Ledger Entry] WHERE [Item No_] LIKE 'I%' AND ( [Location Code] = 'WH-AB-#2' ) GROUP BY [Item No_] ) SELECT cte.[Manufacturer Code],cte.[Description], CONVERT(int, cte2.[Qty]) AS 'Qty',CONVERT(int, cte.[Unit Price]) AS 'Unit Price' INTO GetDataForUpdate_temp_tb FROM cte JOIN cte2 ON cte.[Item No_]=cte2.[Item No_] WHERE rn = 1 ORDER BY cte.[Item No_],[Starting Date] But after execute, lefts only this part of query in store procedure: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[GetDataForUpdate] AS if exists(select * from sys.objects where name='GetDataForUpdate_temp_tb') begin DROP TABLE GetDa

SQL Insert with Index Scan Problem....

Hi,   I'm having a very strange problem when inserting rows into a table. Let me try to explain a little better: Table1 (for example Book) with a lot of fields and one foreign key to Table2 (idVolume) and a primary key (identity - idBook). This table has a clustered index only on the primary Key. (this table has something like 10 Millions rows) Table2 (for example Volume) with a lot of fields and a primary key (idVolume) identity. (this table has hundreds of rows)   Now, the problem starts when I make a insertion on Table2. When I made an insertion, it was taking minutes to finish, so I stopped it. After looking into the execution plan of the query, there was something very very strange, there seems to be a clustered index scan on Table1... the problem is that since Table1 has so many rows, this index scan takes forever... Can anyone explain me why does the insertion on Table2 makes an clustered index scan on Table1? It really doesn't make any sense to me.   Thanks in advance. João Teixeira

Basic data type problem with database insert

Hi,I'm trying to write some values into a database, but I think there's an issue with the data types.  Here's what I've got: public static string Hello(string pageId, string inOut) { string itemId = ""; string period = ""; var cookie = HttpContext.Current.Request.Cookies["visitorGUID"].Value; SqlConnection conn; SqlCommand comm; conn = new SqlConnection(GlobalSettings.DbDSN); comm = new SqlCommand("INSERT INTO myTable (memberGUID) VALUES (@memberGUID);", conn); comm.Parameters.Add("@memberGUID", System.Data.SqlDbType.Text); comm.Parameters["@memberGUID"].Value = cookie; try { conn.Open(); comm.ExecuteNonQuery(); return "Item added: cookie = " + cookie + " / pageId = " + pageId + " / inOut = " + inOut + " / pageId = " + pageId + " / itemId = " + itemId + " period = " + period; } catch { return "Item caught: cookie = " + cookie + " / pageId = " + pageId + " / inOut = " + inOut + " / pageId = " + pageId + " / itemId = " + itemId + " period = " + period; } finally { conn.Close(); } } At the moment I'm just trying to insert the value of the cookie into the database as a test.  It works fine when I

Lookup transform partial cache problem.

Hi, I've a simple lookup transform in SSIS 2008 (R2). I've created it with a full cache and it worked fine. When i switch to partial cache, it will give me this error: -------------------------------------------------------------------------------------------------- TITLE: Package Validation Error ------------------------------ Package Validation Error ------------------------------ ADDITIONAL INFORMATION: Error at DFT_AdventureWorks [Lookup [411]]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "Syntax error, permission violation, or other nonspecific error". Error at DFT_AdventureWorks [Lookup [411]]: OLE DB error occurred while loading column metadata. Check SQLCommand and SqlCommandParam properties. Error at DFT_AdventureWorks [SSIS.Pipeline]: "component "Lookup" (411)" failed validation and returned validation status "VS_ISBROKEN". Error at DFT_AdventureWorks [SSIS.Pipeline]: One or more component failed validation. Error at DFT_AdventureWorks: There were errors during task validation.  (Microsoft.DataTransformationServices.VsIntegration) -------------------------------------------------------------------------------------------------- i've

HttpRuntime.Cache problem

I'm using the code below (a shortened version as a test). It is invoked on application start and collects data for use by the individual sessions.  The problem I'm having is it doesn't work on one machine but is fine on the other Is using .Clone the correct way of caching or is that the cause of my problems?   Public Shared Sub LoadGroups()                  Dim arrGroups As New ArrayList          for i = 1 to 100               arrGroups.Add("test" & i) Next        HttpRuntime.Cache("Groups") = arrGroups.Clone       Thread.Sleep(2000)  End Sub 

Bulk Insert Problem

I am trying to perform a bulk insert on pipe delimited file (approx 25 columns,5000+ rows of data).  Normally this is no problem however this file has a header and trailer record with no delimiters (1 column).  I could use a utility like grep to remove the header/trailer record but I would like to capture the entire file inside sql server. I can bulk insert the entire file into a single column (wide) that would include the delimiters.  My problem from there is to process the single column data into the appropriate rows /columns.  I am looking for a set solution as opposed to a cursor type solution. HTML?  Seems slow.  Cross Apply?   Changing the file format is not a viable solution. I’m likely to have more than a few of these oddball formats with a variable number of columns.  Any ideas?   I thank you for your time on this puzzle.

problem with cache

Hi all,I have problem in cache. I have stored data in cache. and according value in cache i am navigating to respective page.but in following function it is not going to respected page.following is code snap. Cache["BizID"] = BizID;                                                         //Add Recommendation flag in cache.                             Cache["RcmdFlg"] = "True";                             Int64 rcmdID = Int64.Parse(this.GridView1.DataKeys[rowIndex][0].ToString());                             Cache["RecoID"] = rcmdID;                             Cache["srvcid"] = Int64.Parse(this.GridView1.DataKeys[rowIndex][4].ToString());                                                                   &n

cache problem

Hi all,Here is my scenario.In default.aspx page user selects the country, state, city from drop down list, and store them in cache for further use. but when other user open the web site  from other computer it shows the same country, state, and city selected by user 1. Is there any problem related to  cache? I have stored data as following.cache["ctryID"] = ctryID;cache["stateID"]= stateID;cache["cityID"]= cityID;I want to show  default country, state , city at page load of default.aspx how can this be done?Please help me

insert date problem when culture is arabic



I want to insert date value in database

when my page loads i am setting the culture into ar-sa

and when insert date i am getting the problem

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Public Sub Add_Date(ByVal title As String, ByVal Schedule_date As Date)
            command.CommandText = "sp_Schedule_DML"
            command.CommandType = CommandType.StoredProcedure
            If Schedule_date = Nothing Then
                command.Parameters.AddWithValue("@optSelect", 0)
                command.Parameters.AddWithValue("@title", title)
                command.Parameters.AddWithValue("@sdate", System.DBNull.Value)
                command.Parameters.AddWithValue("@optSelect", 0)
                command.Parameters.AddWithValue("@title", title)
                command.Parameters.AddWithValue("@sdate", Schedule_date)
            End If
            If connection.State = Data.ConnectionState.Closed Then
            End If
            If connection.State = Data.ConnectionState.Open Then
            End If
        Catch ex As Exception
            Throw New Exce

Insert XML data into table problem


For the life of me I cannot figure out what's wrong with my SP. I'm receiving an XML document with a bunch of invoices like


And I need to write each invoice as a record in SQL Server 2005

I'm getting the following error

Msg 170, Level 15, State 1, Procedure pcdAddInvoices, Line 39
Line 39: Incorrect syntax near '.'.


 -- Add the parameters for the stored procedure here

 @msg xml
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.

    -- Insert statements for procedure here
 INSERT INTO [Promacoin].[dbo].[Tblinvoices_DAX] (ObjectID,ActivityID,ResourceID,ContractID,Document
 SELECT M.Invoice.value('/ObjectID','NVARCHAR(16)') AS ObjectID,

HttpRuntime.Cache IIS problem?


I get the leisure of debugging someone elses project in which a customer logins and gets their status page. Now this status page shows redeemed information, but the odd thing is if you refresh several times you could possibly get someone elses information. It just happens randomly to, but I would hit F5(refresh) and check it several times and it would be a completely different item and then repeat that it would be back to normal. I did this for about 2-3 minutes and it would be totally random. Now my question is he is using HttpRuntime cache to store this information at login and then retrieving them from HttpContext.Current.Session.  Is there a setting in IIS that could be causing me to get someone elses cached item?

Also there needs to be several numbers stored(up to 4) and pass to a few pages on the site. Is there a more effient way rather than using HttpRuntime.Cache and passing it a array list of a created Class Type?

Problem in inserting another entity via overriding insert method


I have problem to inserting another entity in overriding method of first entity my code sample is like bellow :

partial void InsertEntity1 ( Entity1 instance )


     Entity2 x = new Entity2() ;

tihs.Entity2s.Add(x) ;





in inserting Entity2 I get Exception "The Operation Cannot be perform for the entity because it is not being change track"


DetailsView Get Values on Insert. Major Problem :(



I'm having a problem to get the inserted values from the detailsview. I've tried the following things:

           // Get Value from DropDown
        int TopicID = 0;
        foreach (DetailsViewRow row in ItemsDetailsView.Rows)
            if (row.Cells[0].Text == "Topic")
                 DropDownList TopicDropDown = (DropDownList)row.Cells[1].FindControl("Topic_TopicIDList");
                 TopicID = int.Parse(TopicDropDown.SelectedValue.ToString());


            MsgBox(CType(DetailsView1.Rows(1).Cells(0).Controls(0), Label))

            For Each row As DetailsViewRow In DetailsView1.Rows

                Dim cell1 As TableCell = row.Cells(1)

                Dim value1 As String

                value1 = cell1.Text



            Dim item As New DetailsViewItem(col.ColumnName, row(index).ToString(), col.DataType.ToString(), col.DefaultValue)


            tb = DetailsView1.FindControl("Categorie")
            s = tb.Text


            For Each dvr As DetailsViewRow In DetailsView1.Rows
                If dvr.Cells.Count = 2 Th

ListView - Insert Problem



I have a ListView where I am trying to do an insert.

I put the property "oniteminserting" in the ListView, and created the method in the codebehind of the page.

When I try to insert a record, is not calling the method "ListView1_ItemInserting. I put a breakpoint in the method, but is not calling it.

To call the input method in ListView, I'm doing the following:

oniteminserting = "ListView1_ItemInserting"

And the method:

protected void ListView1_ItemInserting (object sender, ListViewInsertEventArgs e)

I tried to delete the method call in the listview, I went into design mode, I clicked in the ListView, I went into properties, events, I gave a double-click the event ItemInserting to recreate the method. But even so, the problem continues.

Does anyone know what might be happening?

* Sorry for bad English. =)










Msg 4866, Level 16, State 1, Line 1

The bulk load failed. The column is too long in the data file for row 1, column 34. Verify that the field terminator and row terminator are specified correctly.

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.

Msg 7330, Level 16, State 2, Line 1

Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".






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