Efficient Ways To Convert DataSets To GenericCollection (Of ObjectType)?
Feb 24, 2010
I currently have a function that gets some data from the database and puts it into a dataset. The return type on my function is GenericCollection (Of CustomerDetails)
If I do this:
Dim dataset As DataSet = Read(strSQL.ToString) 'Gets Data from DB
What's the most efficient way to map the dataset results to an collection of objects. More importantly, since I'm using GenericCollection, is there a way to do this in which I can call a function from the ObjectType class (CustomerDetails) that would have a means to converting that specific object.
Or is there a way in which I can use a function that would handle all types?
Is there a way to do something like:
Return returnedResults.TransformDataSet(dataset)
In which returnedResults is an object collection Of CustomerDetails, or would it simply be easier to have TransformDataSet return an object collection Of CustomerDetails by itself?
View 1 Replies
Similar Messages:
Sep 23, 2010
How to link multiple DataSets (why SSRS call it a DataSet even there is only one bunch of data fields in it) using keys, then put data fields from multiple DataSets into one Data Region? The reason I have to do this is: There will be 6 major DataSets to be used together few times in same report, it is not make sense to build a huge Matrix for all of them together. (in some data region I use data from dataset A and B, some times I use data from dataset A and C, D ...)
View 2 Replies
May 24, 2010
It's simple to do a webrequest, get the page and parse the html to get the title of the page. But I'm wondering if there is a more efficient way that is faster, and doesn't require downloading the whole html?
View 2 Replies
Jan 16, 2011
I am new to databases and linq, so my problem may be considered trivial. I currently start all my db requests in each class with:
DataClassesDataContext db = new DataClassesDataContext()
Then I proceed to make whatever linq request I need within the method and carry on with the main application logic.
Now, two interesting queries:
1) I believe I have seen people wrapping db usage within 'using'. Such as:
using (DataClassesDataContext db = new DataClassesDataContext())
{
...
}
If this is correct, then doesn't it mean that my class can't use a member 'db' variable anymore, but rather those db requests need to be made within each function call? Also, what exactly would happen if I don't use 'using' within the calls?
2) Running my app with SQL Profiler enabled, I see lots of connections opening and closing. Does this means that each
DataClassesDataContext call makes a separate connection? It seems inefficient, so is the right way to actually make the DataClassesDataContext object a static within each class being used?
View 2 Replies
Nov 17, 2010
I have just started learning asp.net with c# and want to know how to write datasets to XML using asp.net.
Can anyone provide me any example or reference so that I can move ahead.
View 2 Replies
Nov 13, 2010
I have two datasets, each of containing single column. I want to compare each row of first dataset with each row of second dataset and check if any match in the data.How can i implement such a login in VB.NET with minimum iterations.
View 2 Replies
Oct 28, 2010
What's the best way to do this? I have seen quite a few examples that use a Dataview etc. what is the best method. I'm thinking about speed issues when a grid has a few thousand records etc.
this is how I populate the gridview:
Code:
[code]....
View 5 Replies
Jan 29, 2011
I have a requirement where 15 listviews have to be loaded on a web page.But only one shown at a time. Number of columns will be only 2 for each and Number of rows for every listview is very limited.The thing I am not able to decide is the sorting method.1. If I am using the datasource control, it automatically sorts my listview.2. If I am programmatically populating listview , I will have to sort my datatable and rebind to the listview.To use the second method I have to store the datatables in sessions.So taking that into consideration, will datasource control be more efficient ?
View 4 Replies
Jan 19, 2011
Assuming a list of objects, each with an ID, what's the most efficient way of building a carousel, so that each object knows what its previous and next item is. The Last Item's previousId will link to the first item. The first item's previousId will link to the last.
I need the ID of the previous and the ID of the next, as this will be used to populate next and previous buttons on a web page.
I know I could iterate over them, adding placeholders for _next and _prev id, but what's the most efficient way to do this?
I figure my object should look like this:
class Item {
public int Id { get; set; }
public string ItemName { get; set; }
public int Next { get; set; }[code]....
I think I'm looking at this wrong way. Is there a better way of doing this?
View 2 Replies
Jan 20, 2010
I am making a blog application and for the sake of my question I have 2 tables: Posts & Comments. I would like to loop through the posts and use a nested loop to display the comments relating to a specific post. Currently, I am using this code:
[Code]....
Obviously this is a simplified version. Is this the most efficient method of displaying this kind of data?
View 3 Replies
Feb 4, 2010
I am outputting the entire HTML for my server control as follows:
public override void Render(HtmlTextWriter output)
{
output.Write(myStringBuilder.ToString());
}
myStringBuilder is a StringBuilder object that is manually built in a separate private method.Is this an efficient way to do it? Or is it better to pass the HtmlTextWriter to my private method and make multiple calls to HtmlTextWriter.Write()?
View 1 Replies
Aug 26, 2010
What is the most efficient way to transmit messages in WCF? I've done a few basic walkthroughs of WCF and upon analyzing the XML transmission I saw that they were very large by default... Containing what appears to me, as a lot of unnecessary information, for my needs. I'm looking for a way to send the shortest messages possible. How can I trim as much as possible from the XML? Can I remove all the header information. What approach for sending the shortest messages possible using XML in WCF?
View 3 Replies
Jul 22, 2010
I am looking at upgrading a realtime program ASP.NET C#, that takes very frequently updated data and moves it from one database to another.
Currently using a middle man app, that pulls from one and inserts into another using SqlBulkCopy.
Is it better to have the source db server write a flat file and the middle man collect from that flat file?
View 6 Replies
Jan 18, 2011
I would like to use insert statement to the same table with different values, lets say 5 times. What is the efficient way to do this?
View 2 Replies
Jul 28, 2010
I've an arraylist having 30000 items in it, what's the best way of creating a text file on the fly from an ASP.NEt page? Currently I'm using the code below but it times out with large data,
Using fileStr As New FileStream(sFileName, FileMode.Create, FileAccess.Write)
Using writer As New StreamWriter(fileStr)
writer.WriteLine("Error Messages") [code].....
View 3 Replies
Jan 20, 2011
I'm starting to run a few ads on a website, and I'm trying to decide the best way to track performance.
Specifically,What's the most efficient way to count clicks? About the only way I can think of is to link the ad to another page with the ID of the ad as an argument (e.g. adserver.aspx?id=1234). The other page would then update the database and do a redirect to the advertiser's link. However, it seems inefficient to have to load a separate page for this. Are there any other options? Also, it seems like I might need to know stuff like how many clicks occurred in a given week. But storing a separate database row with a date for every single click seems excessive. Has anyone else done something like this? Would it make sense to maybe create a new row for each week and increment a counter for all clicks that occurred that week?
View 2 Replies
Mar 8, 2011
I'm doing some custom code for a SharePoint webpart in C#. Specifically, I'm making a quiz, my main point here addressing the list that holds the question, answer choices, and correct answer.
At the last stage of the quiz I need to check the answers selected by the user against the correct answer in the list. Currently, I'm doing the following to check if each is correct, which I'm assuming isn't very efficient because it iterates through each question. Is there a method, specifically for the SPList foreach loop, that would be more efficient?
// 1. Store questions and answers in class
List<submittedAnswers> answeredQuestions = new List<submittedAnswers>();
// 2. From POST pull answered question IDs and answer IDs (which correspond to the question primary key and answer choice number both stored in the list)
// INSERT BEAUTFIUL AND EFFICIENT WHILE LOOP HERE
// 3. Loop through each question is list, if question was given, test if correct/incorrect
using (SPWeb myWeb = mySite.OpenWeb())
{
SPList answerList = myWeb.Lists[questionList];
foreach (SPListItem quizEntry in answerList.Items)
{
int pullAnswerId = int.Parse(quizEntry["Answer"].ToString()); // Pull answer number from list
int pullQuestionId = int.Parse(quizEntry["ID"].ToString()); // Pull primary key of question
submittedAnswers result = answeredQuestions.Find(delegate(submittedAnswers e) { return e.questionId == int.Parse(quizEntry["ID"].ToString()); });
if (result != null)
{
if (result.responseId != pullAnswerId) // If the response was different from the answer
incorrectAnswers++;
else
correctAnswers++;
}
}
}
// C# quiz grading magic here....
View 4 Replies
Mar 16, 2011
Just for curiosity, i want to know i how many ways we can write the parameters in a querystring. I have encountered the following
& (is common that we use in our most of the application)
, (in some banking application)
; (bank.co.in/BANKAWAYTRAN;jsessionid, this is from my banks QS :-) )
View 1 Replies
Mar 20, 2010
I have two datasets called ds and ds1 that I want to merge into a grid. I get data from the first dataset to display in the grid but the second dataset where I want to display a count I don't get any data from it. I am trying a ds.Merge(ds1). here is the code i have for the sub. What am I doing incorrectly?
Code:
[code]....
View 9 Replies
Jan 25, 2010
I found an interesting discussion here:
[URL]
Quote:
DataSets are sub-par amateur solutions to code your Data layer...Stop Using Them and learn to CODE! :)
What is your opinion of DataSets vs. just stubbing out custom classes and working with those? What are other alternatives?
View 3 Replies
Feb 5, 2011
I have a good bit of data that is generally static. I want to load it into my application so I can access the items from picklists without having to make redundant calls to the database. I have found a few articles discussing how I can approach this, but, I am specifically looking for a way to create a collection of DataSets with constraints at Application_Start. Also, when you do this kind of thing, do you normally create one dataset or a separate dataset per table? I know there are ways to add multiple tables to a single dataset, but, I don't know how to do this from the DataSet Designer.
View 2 Replies
Aug 26, 2010
I have imports.aspx with an ASP:FileUpload function.In my code-behind I have this:
SEPTA_DSTableAdapters.ServiceTBLTableAdapter sta = new SEPTA_DSTableAdapters.ServiceTBLTableAdapter();
SEPTA_DSTableAdapters.RoutesTBLTableAdapter rta = new SEPTA_DSTableAdapters.RoutesTBLTableAdapter();
protected void Page_Load(object sender, EventArgs e)
[code]...
View 1 Replies
Mar 7, 2011
Now I know Datasets support disconnected operations. but does EF do the same thing?
View 3 Replies
Feb 16, 2011
I am using Visual Studio 2010 now. I do not have network access to my database because of some connectivity issues. Are there any good articles on how to manually wireup Entity Framework objects manually? Or, is this just unrealistic?
View 3 Replies
Aug 2, 2010
I have a listbox on my site that is populated with data. I then have a textbox that is used to enter a search phrase and with each letter that is added the listbox is narrowed down or repopulated using javascript. I use one listbox to store all the items and a secondary showing the listing results. This makes it east to check against all items and then populate the second listbox with all the results according to the search.
Currently this process can cause a delay in updating the listbox (eg when the textbox is emptied all the items need to be repopulated from the listbox with all the data).
What is a quick and efficient way to perform this listbox search?
View 3 Replies