C# - Methods Of Pulling Data From A Database

Dec 21, 2010

I'm getting ready to start a C# web application project and just wanted some opinions regarding pulling data from a database. As far as I can tell, I can either use C# code to access the database from the code behind (i.e. LINQ) of my web app or I can call a stored procedure that will collect all the data and then read it with a few lines of code in my code behind. I'm curious to know which of these two approaches, or any other approach, would be the most efficient, elegant, future proof and easiest to test.

View 3 Replies


Similar Messages:

Forms Data Controls :: Formview Data - Pulling Data From A SQL Database In Cases The Rows Contain One Or More Null Values

Feb 1, 2011

Using a class component, an Object data source and a formview I am successfully pulliing data from a SQL database. In some cases the rows contain one or more Null values and I would like them to be ignored completely. My simple code follows:-

<%# Eval("add_1") & ","%>
<%# Eval("Add_2") & ","%>
<%# Eval("Add_3") & ","%>

OUTPUT:-

Rose Cottage, 123 New Road, Margate,

View 2 Replies

DataSource Controls :: Appending Data To An SQL Server Database After Pulling From An ODBC?

Jul 15, 2010

I am working on an asp webform that pulls from an ODBC datasource then puts the data in an sql server. Once the data is in the sql server several queries pull data from it to provide information for a report.

This is an example of what I am talking about

private
void ODBCpdEmployeeAb()
{
DataTable dt =
new
DataTable();

[Code]....

The first part gets the data from the ODBC connection and the next part stores it in an sql server table. The problem is I have these methods in the page load event of the webform so everytime it loads it just puts the exact same data in the sql server table which would then provide incorrect information on the report.

Is there a way to append the most recent data from the ODBC table to the sql server ?

View 3 Replies

Access :: Pulling Information From The Database?

Jan 15, 2010

I recently designed a website for a school, I have their result in my database, I am using Northwind. What I want to do is, since all the result are in the data, I want to input a students name, exam number and some numbers in a card(exam scratch card, which they will purchase) they will purchase. When they input these details, the students results will be pulled out from the database.

Just like exam result portal, where you will look up your result with, your name, school number and numbers from the scratch card.

View 6 Replies

WebMatrix :: Pulling HTML From A Database And Inserting It In To A Page?

Jul 27, 2010

I have searched endlessly for an answer but found nothing useful! I'm writing a simple blog application using Web Matrix and its going pretty well, but I have run in to a problem. I am storing the content of each blog post in a ntext field in a table with the intention of entering HTML in to the database and then have my application pull it out and insert it in to a few different view pages. The problem is that all of the '<' and '>' characters are getting converted in to '<' and '>' when my application pulls the HTML from the database and displays it. I understand that this is for security (preventing code injection?), but only trusted users will ever be able to write posts using my application. Here is a screen shot of what gets displayed by my application:

Is there a way to disable this behaviour or work around it somehow?

View 3 Replies

DataSource Controls :: Pulling A Date From An Access Database?

May 26, 2010

I am pulling a date from an Access Database and inserting into my Dataset. I am assigning it to "myDate" and then assigning it to my SQL parameter @StartDate.

When I run my ExecuteNonQuery I get a null value in my SQL database. There are no null values in my access database. I must have the syntax wrong.

[Code]....

View 4 Replies

Web Forms :: How To Highlight The Dropdownlist Item After Pulling From And Matching With The Database

Dec 13, 2010

I have two web forms. There is a Button Control on one web form and One DropDownlist on another web form which binds "States" on Page_load().

If i click on button in the first web form which pulls out one state (for ex: VA-Virginia) but it should be highlighted and displayed in the dropdown of next web form.

View 3 Replies

Connecting To Access 2007 Database Linked To SQL Server And Pulling Records?

Jun 10, 2010

I have a issue where I am trying to pull some records from an Access 2007 DB that has linked tables from a SQL 2005 Server. When I go to do this the browser IE8 just sits there and does nothing. THe little progress bar at the bottom moves about half way then that is it. It will sit there and show no errors or do anything. I have experience with connecting and manipulating Access and SQL server DB's but not through Access with linked tables from SQL Server. Here is test code below:

[Code]....

This does not produce an error or anything. The browser just sits there and sits there. Is there something I am missing?

View 2 Replies

Pulling Data From Website In .NET And C#

Jun 14, 2010

I have written a web scraping program to go to a list of pages and write all the html to a file. The problem is that when I pull a block of text some of the characters get written as '�'. How do I pull those characters into my text file? Here is my code:

string baseUri = String.Format("http://www.rogersmushrooms.com/gallery/loadimage.asp?did={0}&blockName={1}", id.ToString(), name.Trim());

// our third request is for the actual webpage after the login.
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(baseUri);
request.Method = "GET";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)";
//get the response object, so that we may get the session cookie.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
// and read the response
string page = reader.ReadToEnd();
StreamWriter SW;
string filename = string.Format("{0}.txt", id.ToString());
SW = File.AppendText("C:\Share\" + filename);
SW.Write(page);
reader.Close();
response.Close();

View 3 Replies

Forms Data Controls :: Pulling A Value From A Gridview?

Jun 28, 2010

I'm trying to pull a value from a Gridview so that I can create a running subtotal. I've looked at a number of examples but they all seem to fail.

Why does this not work? Each and every reference I try to make to the cells "value", comes up null.

Sample code1:

[Code]....

Sample code2:

[Code]....

In sample code 2, I get the "header text" for the column...but I know the value in the cell...so it fails on a data conversion.

View 5 Replies

Web Forms :: ObjectDataSource Concept - From Where Data Is Pulling

Feb 17, 2010

I was hired to do some contract work for a short contract. I am looking at this code on this Aspx web form. What they do is load the labels for a radio button list from an ObjectDataSource object. Well this is the first time I have ever heard of an ObjectDataSource. The problem is that I don't even know where this object is pulling data from. With a SqlDataSource object, I can easily view the flyout menu to see the sql query where the data is being pulled from. Anyway, I need some figuring out where objectDataSourcePlanType lives and where it is pulling data from. I know I can't list the entire project, but I am sure someone who is familiar with ObjectDataSource

<tr>
<td>Type of Plan</td>
<td><img alt="Required" src="/Images/arrow.png" /></td>
<td>
<asp:RadioButtonList ID="radioButtonListPlanType" runat="server" AutoPostBack="True" DataSourceID="objectDataSourcePlanType"
DataTextField="PlanTypeName" DataValueField="PlanTypeId" OnSelectedIndexChanged="RadioButtonListPlanType_SelectedIndexChanged"
RepeatColumns="1" RepeatDirection="Vertical" AppendDataBoundItems="true">
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="requiredFieldValidator10" runat="server" ControlToValidate="radioButtonListPlanType" ErrorMessage="Type
of Plan is required."
SetFocusOnError="true" />
<asp:ObjectDataSource ID="objectDataSourcePlanType" runat="server" SelectMethod="ListPlanTypes" TypeName="Candle.Web.PlanRequest.CommonWeb">
</asp:ObjectDataSource>
</td>
</tr>

View 2 Replies

C# - Pulling Data From Repeater With EnableViewState=false?

Sep 19, 2010

I am trying to avoid enabling EnableViewState..Sample code as you can see has 1 repeater and 2 textboxes inside. I bind the textboxes at page init. After a postback I want to get the updated data from the client & save in a db. The Request.Form contains the data keyed with autogenerated client ids but the repeater has 0 items after the postback. So my options seem limited to.a. Enable viewstate so I can pull the data from the repeater using Control.Find(...)b. iterate through Request.Form and find my textbox values...ultimatly the goal is to to render data from a datatable to some textboxes, allow the user to make changes then save these changes. I'd like to avoid viewstate if there is a clean alternative..ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Foo.aspx.cs" Inherits="Ads_Foo" EnableViewState="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

[code]...

View 1 Replies

Forms Data Controls :: Pulling A Single Data Element From Checkbox In Gridview

Apr 28, 2010

I have a templated control embedding a checkbox in a GridView I have an event on the checkbox which has a loop that pulls ALL of the checked checkboxes and the associated value. I only want to pull the datavalue of the checkbox that I just checked but the properties/methods associated with that checkbox event are not giving me any sort of index or item.value from which to do this.

View 2 Replies

Forms Data Controls :: Adding Checkbox Functionality To a System / Pulling Data From Gridview

Aug 31, 2010

I am currently adding checkbox functionality to a system. I would like to check a group of users and add them into a db table. I currently have the administrator values flowing into the db table fine but it will not insert the empID into the table from the gridview. Here is my code:[Code]....

View 5 Replies

Forms Data Controls :: Time Out Expired While Pulling Data?

Jan 7, 2010

Im generating reports with around 8000 to 10000 records in grid view , my page give me time out error if data exceeds and it gives time out exactly after 30 secs.i have given command time out = 0 in webconfig file , but it still gives me the error . i have been using command time out property in code behind also

View 2 Replies

Pulling Similar Data From Multiple Information Sources?

Feb 1, 2011

So I have been trying to follow serenarules posts about persistence layers, but I seem to be missing something.

The persistence layer is an architectural layer whose job is to provide an abstract interface to information storage mechanism(s).

This makes sense to me, but I am still having a hard time with this.

So in what cases is this necessary? When you are pulling similar data from multiple information sources?

View 7 Replies

Web Sharing Folder/ Data Pulling Is Pretty Slow ?

Feb 25, 2010

we have a program that we work with with in 2 different locations, both of the program instances must share the same database.what i did is to open Web Sharing folder on our server then i added on both computers this folder to their "My network places" and direct both of application to this folder which contains the database.this is how i direct the program :

Code:

D:WNKKWnkk.exe \MyServerktest
nk2008

it all works fine but there is one problem, the data pulling is pretty slow when it shouldn't we have 100MB download / upload on our server and over 10MB dl/ul in our office.

some pointers:i added the shared web folder to one of our website directory and thats mean that the port the program is using is 80
is port 80 is slower then others?

View 10 Replies

DataSource Controls :: Unique Numbers For Pulling Data?

Feb 3, 2010

I currently designed a school result portal. If the students want to view their result, they input their student school number in a text box to search out their result. But this is not secured because anybody can look up any students result if you have the number which is even written on their school uniform for identification.

I have being trying to secure this result by trying to generate or code special numbers that the students will input with their school number. The special numbers will be random numbers and may be from 10 and above, it might even contain letters. How do
I code this. I believe this is the best asp.net forum. I want the students to be inputing this special unique numbers and their student numbers so that there result will be avaliable to them.

View 2 Replies

Forms Data Controls :: Pulling The Value Of A TemplateField From A GridView?

Nov 23, 2010

I have a GridView, bound to a table (Meals) in a SqlDataSource.

Into that GridView, I have added a TemplateField, which contains a DropDownList (which displays the numbers 1 - 10, added manually; no Data Binding). And, I've added a ButtonField.

When I click the Button, I want the values of some of the GridView rows PLUS whatever value was selected in the DropDownList to be pulled out and stored in a second Sql table (Orders).

Pulling the rows bound to the SqlDataSource is easy but JavaScript is needed (I think) to pull the SelectedValue from the DropDownList. I understand women more than understand JavaScript (that's how little I know) and the code below has been kindly offered by another forum user who is at a loss, himself, now.

Here's the code and the error message I'm getting.

ASPX:

[Code]....

And here's the Code Behind:

[Code]....

No design time errors reported but here's the run time error:

Object reference not set to an instance of an object.

On the following line:

Line 28: if (row.RowType == DataControlRowType.DataRow)

View 6 Replies

Forms Data Controls :: Pulling Data From Gridview To Use In Same Row

Oct 7, 2010

I use a gridview with products, in which one column lists the manufacturer, and the next colum lists the item number.This gridview works fine, but now I want to add a product image on the same row. Instead of using a stored image location, I simply want to make a link to the image like this:

"www.mywebsite.com/images/manufacturer/itemnumber.jpg "where the manufacturer and the itemnumber are the same as displayed in that particular row in the manufacturer and itemnumber columns. I am not versed well enough (yet???) to reuse the data from those two columns.

View 2 Replies

DataSource Controls :: Storing And Pulling Data In DB To Get Google Map Location

Jul 22, 2010

I have this simple project which needs to show location on a google map by pulling data from the DB.I am using asp.net, mysql DB, google map and i found out from some website that i needed to use ajax.

The process is like this

1. I have a event form where i have multiple fields to fill in and it includes a Location/Venue fields which i can enter a location by Name(Not the Co-ordination). I am located in Singapore. So all fields will be stored into the DB.

2. I have a webpage displaying a table of the data from the same DB, and it comes with a embedded Google Map. On the table, the value of the Location column will be Hyperlinked, and when i click it, it will act as a search query in the embedded google map and locate the address without reloading the page again(which i believe i gotta use iframe?)

View 3 Replies

Sharing Single Database Connection Between Several Methods Simultaneously?

Feb 8, 2010

I have a page where a user can insert some order about some product. In that page there are also live statistics which is being refreshed every 20 seconds to reflect the current price of a product using asp.net timer. This live panel fetching these prices from a database.

When sometimes an order is being inserted, I get an exception saying that the connection is closed and the insert command cannot continue. I suspect that when the insert command is given, if at that exact moment the live update is being refreshed, then they both need to access the database, and they are using the same SqlConnection Object. So when one finishes, the connection object being closed even if the other one is using the same connection object.

Before closing a connection, how can I be sure that no other methods are using that connection?

The code of my connection class is given below, for better clarification -

[Code]....

View 4 Replies

Create Methods To Do Stuff Like Opening The Connection To The Database?

Jun 22, 2010

I want to be able to create methods to do stuff like opening the connection to the database.Right now if I want to do that I have to put all the code to open the connection with the database in every class.What I did is create a new class called methods, this class is in the App_code folder.I have researched but don't understand how methods are created and how to call them. If someone can give me an example regarding a database connection method, I might be able to really understand how a method works. Basically, this is the code I have to use everytime I want to open a connection to the database:

string connectionString = ConfigurationManager.ConnectionStrings["dbConn"].ConnectionString;

View 7 Replies

Using Extension Methods In Static Methods On Extended Classes?

Aug 16, 2010

I have an extension method as follows:

public static class PageExtensions
{
public static int GetUserId(this Page targetPage)
{
var user = Membership.GetUser(targetPage.User.Identity.Name);
return (int)user.ProviderUserKey;
}
}

Now in a page I need to use this method in a static WebMethod, so I have added another 'extension method' to PageExtensions:

public static int GetUserId()
{
return (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
}

and I call it as follows in my WebMethod: PageExtensions.GetUserId()

View 1 Replies

Web Forms :: How To Change This Methods In To Use Dictionary Or Extension Methods

Jul 23, 2010

public class CacheHelper { /// <summary> /// Removes object with the specified key. /// </summary> /// <param name="key">The key.</param> [code]....

I have this methods for caching..I need to change this methods to use in aDictionary<string,object>

How do I need to change this code Because I am new to asp.net I am still learning..

View 12 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved