ADO.NET :: When To Use 'reader' Versus A Datatable, Table Adaptor?
Sep 20, 2010
I'm making the leap from using all the 'wizards' that are built into VS, and have been doing more with code-behinds. But, I'm curious as to when/why I should use a reader, versus a databable, table adaptor to "manage" the data returned from a stored procedure. Typically, the data is to be displayed on a webpage, and not written back to the database. What's the difference? When should I use one over another?
View 2 Replies
Similar Messages:
Jan 6, 2010
I'm currectly tryin to access a specific value in my database in a specific column. I'm tryin to use the primary key of the table to access the actual value in the row of that ID.
The current code:
[Code]....
Just iterates through the table and looking for any row with the boolean 'checkin' value is True, then it takes the 'id' value of that row and stores it into an array. Is there a way that I can access a another entry, and only that entry, in the table with the 'id' stored in the array?
Like if my data base contained and int, primarykey, `id` value, a boolean, `checkedin` value, and a `time` value, is there a way to access, lets say, the row with `id` equalling 3 and and the checkIn value from that row?
View 2 Replies
Dec 18, 2010
Had a datareader question.
[Code].......
Return myDataReader I have a function which is retuning a datareader to various sections of my website which is then being bound to dropdown lists, gridviews, etc. Normally the last line in a function when is the data reader and connection getting closed? Is it best practive to return a data reader or a dataset/datatable (or something even better than these two)?
View 8 Replies
Dec 24, 2010
is it possible to find row count of a table using data reader?
View 3 Replies
Feb 22, 2011
I have some code in my vb.net code behind that queries a database, and if there is data, outputs it from the codebehind to a datalist on my asp.net page. In addition to sending the data to the datalist on the page, I need to take the value from "mbillaty" that is returned from the sql query, and have that value be the selected value for a drop down box also on the page. I can get either the datalist to fill, or the selected value for the dropdown box to be selected depending upon which bit of code I place before the other (ARGH), but I can't get them to both work together on the page. What am I doing wrong?
[Code]....
View 2 Replies
Apr 10, 2010
I have been able to successfully read a row of data from an SQL table using two column parameters. Now I would like to update this row with new information. Is this possible since the reader does not specify which row was read with the 'reader.Read();' command?
View 7 Replies
May 17, 2010
use a profile table to store information that's not present in membership table (like country, age, etc.), or customize a membership?
View 1 Replies
Sep 16, 2010
What is the difference between; Deploying an application Releasing an application Implementing an application
View 1 Replies
Jul 23, 2010
I've gone rounds with this ever since I started programming classic ASP 12 (or so) years ago and I've never found a great solution because the architecture of ASP and ASP.NET has always been a swamp of bad practices, magic shared singletons, etc. My biggest issue is with the HttpApplication object with its non-event events (Application_Start, Application_End, etc.).
If you want to do stuff once for the entire lifespan of an HTTP application, Application_Start is the obvious place to do it. Right? Not exactly. Firstly, this is not an event per se, it's a magic naming convention that, when followed, causes the method to be called once per AppDomain created by IIS.
Besides magic naming conventions being a horrible practice, I've started to think it might be a reason there exist no such thing as a Start event on the HttpApplication object. So I've experimented with events that do exist, such as Init. Well, this isn't really an event either, it's an overridable method, which is the next best thing.
It seems that the Init() method is called for every instantiation of an HttpApplication object, which happens a lot more than once per AppDomain. This means that I might as just put my startup logic inside the HttpApplication object's constructor.
Now my question is, why shouldn't I put my startup logic in the constructor? Why does even Init() exist and do I need to care about Application_Start? If I do, can anyone explain why there is no proper event or overridable method for this pseudo-event in the HttpApplication object?
And can anyone explain to me why in a typical ASP.NET application, 8 instances of my HttpApplication are created (which causes the constructor and Init to run just as many times, of course; this can be mitigated with locking and a shared static boolean called initialized) when my application only has a single AppDomain?
View 2 Replies
Aug 14, 2010
I have AspTable which is full of data
Table TableDDl = new Table(); and I have DataTable
DataTable DataTableDDl = new DataTable();
who can I put the same data from AspTable in the same place in DataTable ?
Ex...If I have "Hello" in (third row and first cell) in AspTable....Who can I put "Hello" in (Third Row and First Colum in DataTable) >>>But for add data...
I try
DataTable1.Load(Table1);
But it didn't work because it want a reader....I want the same thing but With AspTable
View 2 Replies
Mar 18, 2010
The current solution i implemented is awful!
I use a for... loop for inserting records from an ADO.NET data-table into an SQL table.
I would like to insert at once the data-table into the SQL table, without iterating...
View 2 Replies
Jan 12, 2011
I have a datatable with a,b,e,f as cols My table is having a,b,c,d,e,f cols for this i am using :
[Code]....
I have upload the data from datatable to sql table with exact cols.
View 4 Replies
Jan 26, 2010
I have a textbox and a search button i trying to search file names in a database table and display them in a datatable...
private void GetSearchResults(string machineID, string searchFileName)
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection();
connection.ConnectionString = ConfigurationManager.ConnectionStrings["SumooHAgentDBConnectionString"].ConnectionString;
connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT FileID, BuFileName FROM BackedUpFiles WHERE BuFileName Like '%@searchFileName%' AND MachineID=@machineID", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlCmd.Parameters.AddWithValue("@machineID", machineID);
sqlCmd.Parameters.AddWithValue("@searchFileName", searchFileName);
sqlDa.Fill(dt);
}
everything is working fine except that the searchFileName is not working in the query...
I tried putting just a value to check like
SELECT FileID, BuFileName FROM BackedUpFiles WHERE BuFileName Like '%b%' AND MachineID=@machineID
View 3 Replies
Aug 12, 2010
I have a table say, Student.
I have a class 'Student'.
I want to populate IList<Student> with objects of Student class from Student table in database.
Is it possible to implement this?
If yes then how to implement this.
View 2 Replies
Dec 11, 2011
I have a DataTable for which i do not know how many rows are there in it.. How to get the rows/columns one by one and save it in the desired SQL Table?
View 1 Replies
Apr 9, 2010
I'm returning one table. My understanding is that a DataSet can be made of more than one DataTable. I also understand that I can use either of these to return my one table.
Is it better to use the DataTable when I have one table to return instead of a DataSet? Is there any advantage of not using the DataSet in a situation like this? Is there a disadvantage to using the DataSet when only one table is being returned? Does this even matter?
View 6 Replies
May 6, 2010
How could I parse a Json string with all the data from my table to a DataTable or a DataView?
View 5 Replies
May 7, 2015
How to fetch datas from sql server and show in html5 div tag?
View 1 Replies
Jan 29, 2011
I would like to send json data from a HTML table to the ASP.NET code-behind and update the data in and SQL Server database. The code and JSON for the TableProductToUpdate() is below.
function UpdateProductTable() {
$.ajax({
type: "POST",
url: "Default.aspx/UpdateProductTable",
data: "{'products':" + JSON.stringify(TableProductToUpdate()) + "}",
[code]...
View 2 Replies
May 3, 2010
I am working on one project which is totally related to Trading.i am working on one module of invoice generation .here i used temporary table .all the product which is selected by the customer , first those all are stored in " data table" and when i am going to press submit button all product or data stored in data table directly stored in Database... i don't know how to clear that temporary table on button click....
View 3 Replies
Jan 20, 2011
'DataTable' is an ambiguous reference between 'System.Data.DataTable' and 'Microsoft.Office.Interop.Word.DataTable'
View 3 Replies
Nov 1, 2010
I am trying to populate a gridview using two tables. I also have a strongly typed dataset and used the method on this page: [URL] the problem is that, when i try to use two table the gridview does show up (I checked through debugging that the datatable comes back as empty).
View 2 Replies
Dec 21, 2010
I have a detailsview, template as follows:
[Code]....
Codebehind: creating dataset, getting data from sql with adaptor and filling into dataset object, then setting detailsview's datasource.
I add 2 button to above template to able to edit data at asp page, and added event handlers:buttons:
[Code]....
My question is, what to do inside the detailsview update event function to able to edit and update data. My method can be wrong too.
View 7 Replies
May 5, 2010
as a php developer ive been told to go the MVC route which ive been trying since yesterday. Im using visual web delveloper 2010 express and im using the MVC template project.Ive basically got a news table in MSSQL Express, in there are these fields ID,(Title,Body,PostedOn,PostedBy) all i wanna do is loop through them to put them on the view.Im after a nudge in the right direction, I want to be able to do a SQL lookup in the controller put that data in a DataTable then run a foreach loop on the table to display this on the view. The problem im getting is I know youre not suppsed to put any HTML in the controller and I cant pass the datatable to the view to do the loop in the view.. so where/how do I do the loop.
View 2 Replies
May 10, 2012
after a query execution i get the data in datatable which is binded to grid.
i need to insert data frm this data table to a sql temp table but with only few selected columns
View 1 Replies