Forms Data Controls :: Collections Versus Reading Database Every-time

Jan 18, 2010

1. I know about collections but I dont remember the precess. I know you drag a sqldatasource control on the form(Select everything in the database ie. selct *) and then delete it. But how do I use it i code.

Example. I need to select services where country=canada from the Agencies table.

2. I know how to manually pull data from an access database using the code below. I want to know how to pull data from a sql database just like the one below.

3. explain the difference between Collections and manually pulling it like the one bellow?

<code>
<script>
Stringpath = Server.Mappath = Server. MapPath(/website");
String connStr = Provider=Microsoft.Jet.OLEDB.4.0" +"DataSource="+path+
\Database;
OleDBConnnection conn = new OleDBConnection(connStr);
conn.open();
OleDbCommand cmd= new OleDBCommand();
cmd.COnnection = conn;
cmdCommandText = "Select * From [Suppliers];
OledbDataReader dr= cmd.ExecuteReader();
Response.write(dr.getvalue(1);

View 1 Replies


Similar Messages:

Inconsistent Result While Reading Collections From Web.Config?

Oct 21, 2010

Is there a reason why i get different result when reading collections using WebConfigurationManager.GetSection method.

It sometimes returns values correctly in the Hashtable and at other times returns nothing for the same data. Its inconsistent.

client:-

Hashtable hsh = (Hashtable)WebConfigurationManager.GetSection("test1");

Config:-

<section
name="test1"
type="System.Configuration.DictionarySectionHandler"
/>
<section
name="test2"
type="System.Configuration.DictionarySectionHandler"
/>.......

View 1 Replies

Reading A File Into Memory And Then Reading It One Line At A Time?

Mar 7, 2011

I know this is probably a pretty easy thing to do and it is if I can upload the file and store it onto the hard drive of the server. What I need to do is read the text file into memory and then parse through it one line at a time. Anyone have any code that demonstrates that?

View 8 Replies

Pros/cons Of Reading Connection String From Physical File Versus Application Object

Apr 9, 2010

my ASP.NET application reads an xml file to determine which environment it's currently in (e.g. local, development, production).

It checks this file every single time it opens a connection to the database, in order to know which connection string to grab from the Application Settings.

I'm entering a phase of development where efficiency is becoming a concern. I don't think it's a good idea to have to read a file on a physical disk ever single time I wish to access the database (very often).

I was considering storing the connection string in Application["ConnectionString"].

[code].....

I didn't design the application so I figure there must have been a reason for reading the xml file every time (to change settings while the application runs?) I have very little concept of the inner workings here. What are the pros and cons?

View 2 Replies

Forms Data Controls :: Sorting And Filtering Collections?

Jan 21, 2010

I have a BLL that takes data from DB into datatables and for each datatable there are functions that transform them into Collections of the corresponding class.

When I put the data in a Collection into GridView through ObjectDataSource I don't have the option to click on the header of a column and get the data sorted. The headers are only clickable when DataTable is passed to the ObjectDataSource.

How can I get arround this problem without passing DataTables to the ODS?

View 1 Replies

Forms Data Controls :: Possible To Output Collections Of Arrays Through Control?

Nov 17, 2010

Using VB.net: I have several collections, each collection has several items and each item has several 1-d arrays (all the same length). Is it possible to print each one of these arrays through an ASP Control?

View 2 Replies

Web Forms :: Reading From Database Without Using Templated Controls?

Mar 13, 2011

I want to read from database without using templated control like gridview, listview ...etc I am being able to read from db, but shows only the first row;

My .aspx pgae is;
<div>
<asp:DropDownList
ID="ddlCustomer"
runat="server"
AutoPostBack="false"
OnSelectedIndexChanged="ddlCustomer_SelectedIndexChanged"
DataTextField="CustomerName"
DataValueField="CustomerID">
</asp:DropDownList>
<div>
<asp:Button ID="btnGetCustomers" runat="server" Text="Button" OnClick="btnGetCustomers_Click" />
</div>
<div>
<asp:Label ID="lblOrderDate" runat="Server" style="border:1px solid #ccc;" width="100"/>
<asp:Label ID="lblOrderName" runat="Server" style="border:1px solid #ccc;" width="100"/><br />
</div>

and code-behind;

[Code]....

View 5 Replies

Forms Data Controls :: How To Bind Grid To Using System.Collections.Generic.List

Mar 25, 2011

I get this error when run the page

DataBinding: 'System.Int32' does not contain a property with the name 'item'.

protected void Page_Load(object sender, EventArgs e)
{
List<int> item = new List<int>();
{
item.Add(25);
item.Add(50);
item.Add(520);
item.Add(543);
item.Add(543);
item.Add(55);
};
GridView1.DataSource = item;
GridView1.DataBind();
}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="true">
<Columns>
<asp:TemplateField HeaderText="Sub total">
<ItemTemplate>
<asp:Label ID="subTotalLabel" runat="server" Text='<%#Eval("item")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="grandTotalLabel" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

View 5 Replies

Forms Data Controls :: Display Time Value That Retrieves From Database

Feb 8, 2010

I am using a repeater control, and in that one of the item, displays a time value that it retrieves from a database, the issue now is, that i want the data to get processed eg, todays date [ minus ] the date that was retrieved from the database. How can i go about this?

I am expecting to use the vb code behind to process the data, and then display it in the repeater control pragmatically for each corresponding record that is displayed.

Snippet of my aspx page:

[Code]....

View 18 Replies

Forms Data Controls :: How To Create Timetable By Retrieve The Time From Database

Feb 26, 2010

Recently i am develop a tuition center management systemNow i want to show a timetable which admin can view and know what time the class room is emptyMy timetable is : On the top of x-axis is time (8am, 9am, ...)On the left of y-axis is date (monday, tuesday, ...)In database i will define the start time and end time for each class

View 6 Replies

Forms Data Controls :: Date Time In Text Box Not Inserting Into Database Table?

Mar 13, 2010

In short, I have 3 text box fields on an .aspx page named as follows:-

TextBoxIncident
TextBoxDate
TextBoxDescription

in addition a sql datasource is on the page which is connected to the incident table with an insert query which allows the data entered into the fields to be inserted into the database...

The Textboxincident and textboxdescription fields allow the user to enter data into them...

the TextBoxDate field is a read only and the code behind file enables the text box to show the current date and time the code im using is shown below...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim TextBoxDate As TextBox
TextBoxDate = FormView1.FindControl("TextBoxDate")
TextBoxDate.Text = DateTime.Now
End Sub

When run in browser the textboxdate field shows the current date and time...and Once the textbox incident and text box description fields have been filled in and the submit button is clicked, the fields should be bound to MS SQL table called Incident. This did work before, however it as suddenly stopped working and now displays the following message to me:-

Arithmetic overflow error converting expression to data type datetime. The statement has been terminated.

View 2 Replies

Forms Data Controls :: ADO.NET Versus SqlDataSource

Jun 29, 2010

I am developing web-app in .NET for 5 months (and enjoying it =)) and I am reading 3 books, all of them teachs at least 2 methods for acessing data: ADO.NET and SqlDataSource object.

I am used to work with ADO.NET method because I feel that even if it needs coding by hand, I can separate the SQL routines from the page and I can customize database routines better.

For now I am using DataReader mode because the application and the database is on the same server and there is only 1Gb RAM available so there is no advantage using DataSet on this moment.

Am I thinking this right? There are some things with SqlDataSource that I don't know how to do it well...

For example:

I have a routine that inserts a record on a table then gets the ID of this record using SCOPE_IDENTITY() function of SQL Server, than it uses this ID to insert another record on another table. Because I use a one-to-many relationship on multiple tables...

How can I work this situation using SqlDataSource object, is it even possible?

View 2 Replies

Code Versus Database - Sequence Of Steps, Call Database Or Check Session Object?

Aug 3, 2010

I have several web sequential pages which will modify a record and its child records in the database, called a "project". Such a project is currently passed between pages using its database ID in the URL parameters.

A project has some information specific to itself, and also consists of one or more Tasks, which each have information specific to itself.

Is it faster (alternatively, more maintainable or more easily understood) to hit the database each time I need to query the same project (and its tasks), or should I query the database once (either once for each page or once for all pages and save to Session) and check the saved object rather than the database?

View 2 Replies

Architecture :: Binding Of Gridview With Database Versus XML Layer / Database

Apr 13, 2010

I am having serious performances issues with gridview + tabs. Its very slow.. I was thinking to create a XML based logical layer between my database and UI.

1) Will it be useful if i use webservice to get data from database to poppulate gridview?

2) or Use xml + some service (need advice on it)

View 3 Replies

Reading A .csv File And Outputting Data To Database?

Jan 25, 2011

I have a csv file with 5 columns. I need to read this file using c# and have to write the contents to the table in database which has 5 columns to it.

if anyone know the code or steps to do this.

View 8 Replies

SQL Server :: Reading Data From .CSV File Into Sql Database

Jul 15, 2010

I urgently need to find a way of reading data from a .CSV or .xls(Excel) file into an sql database so that I can use it in my asp.net 2.0 application.

View 4 Replies

WCF / ASMX :: Reading Data From Database Using Web Service

Apr 25, 2010

I have a requirement in which i have a database table which has 4 columns Id,Name,position,city.....now i have a form in which the user will be filling in the id and then the other three columns should auto populate ....now i want a web service which will make a data connection and get the Id from the form and then query the database and get the other three columns..i am pretty new to web services ..can somebody give me some heads up on how to achieve this...let me know if i have to provide more details.

View 8 Replies

Databases :: Reading Excel Data To SQL Database

Sep 23, 2010

Using C# to develop an application.I need to upload data ( which is in excel) to a sql table.

[Code]....

View 1 Replies

DataSource Controls :: Reading Information From Database?

May 16, 2010

I would like to check my database for to see if a user name is available but my script isn't working.

I am taking input from a text box call unametextbox and i'm trying to extract any matching username from the database, this is my code.

[Code]....

View 8 Replies

Reading - Parsing And Posting Data From A .csv File Into A SQL Database

Jul 13, 2010

I have the following data that basically I only need a few bits of information from:

Resource:X - Y;Z - Å;Type:(all) From Date:
07/12/2010 - To Date 07/12/2010 Sort
by:Time Include Referring
source/physician:No Footer:Default
Criteria:None
","Appointments","X,
Y","ZAssociates","Monday, July 12,
2010","Time","Patient Name","Patient
ID","Appt. Type","Ref. Source/
Physician","Phone","Type","DOB
","Z, X","Y","7/12/2010
12:00:00AM","Time","Patient
Name","Patient ID","Appt.
Type","Phone","Type","DOB "," 7:30
[snip]

The only things I need from this are:

Patients Name
Drs Name
Patients Phone Number
Appt Time
Appt Date

and the rest of the information I can discard. A customer uploads this as a .csv file (even though it really isn't as you can see) and I'd like to parse the needed information and post that to my SQL database and discard the rest. I think I can do this with a dataset but I've never built that before. The fields from the customer will always be the same and the fields I will need will always be the same. Also, the date time has to be in the format of yyyy/mm/dd:hhmm and the phone number always has to have 512 as a prefix. Here is the code I currently have for my site:

Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Submit1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim SaveLocation = "\xxxWEB3wwwrootWebfile1RemindersDoug_Ancildoug.csv"
If UploadFile(SaveLocation) Then
'the file was uploaded: now try saving it to the database
SaveToDatabase(SaveLocation)
End If
End Sub
Private Function UploadFile(ByVal SavePath As String) As Boolean
Dim fileWasUploaded As Boolean = False 'indicates whether or not the file was uploaded
'Checking if the file upload control contains a file
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
Try
'checking if it was .txt file BEFORE UPLOADING IT!
'You used to upload it first...but the file could be a virus
If File1.FileName = ("doug.csv") = False Then
'The file is not the expected type...do not upload it
'just post the validation message
message.Text = "Sorry, thats not the correct file."
message2.Text = "Please locate and upload 'doug.csv'"
Else
'The file is a .txt file
'checking to see if the file exists already
'If it does exist Deleting the existing one so that the new one can be created
If IO.File.Exists(SavePath) Then
IO.File.Delete(SavePath)
End If
'Now upload the file (save it to your server)
File1.PostedFile.SaveAs(SavePath)
'After saving it check to see if it exists
If File.Exists(SavePath) Then
'Upload was sucessful
message.Text = "Thank you for your submission."
fileWasUploaded = True
Else
'the file was not saved
message.Text = "Unable to save the file."
End If
End If
Catch Exc As Exception
'We encountered a problem
message.Text = "Your file was not in the correct format. Please contact Customer Service at xxxx-xxxx-xxxx."
End Try
Else
'No file was selected for uploading
message.Text = "Please select a file to upload."
End If
Return fileWasUploaded
End Function
Private Sub SaveToDatabase(ByVal SavePath As String)
Try
Dim sqlQueryText As String = _
"BULK INSERT dialerresults " + _
"FROM '" & SavePath & "' " + _
"WITH ( FIELDTERMINATOR = ',' , ROWTERMINATOR = '
' )"
' and bulk import the data:
'If ConfigurationManager.ConnectionStrings("Dialerresults") IsNot Nothing Then
'Dim connection As String = ConfigurationManager.ConnectionStrings("Dialerresults").ConnectionString
Dim connection As String = "data source=10.2.1.40;initial catalog=IVRDialer;uid=xxxx;password=xxxxx;"
Using con As New SqlConnection(connection)
con.Open()
' execute the bulk import
Using cmd As New SqlCommand(sqlQueryText, con)
cmd.ExecuteNonQuery()
End Using
End Using
'Else
'message.Text="ConfigurationManager.ConnectionStrings('Dialerresults') is Nothing!"
'End If
Catch ex As Exception
message.Text = "Your file was not in the correct format. Please contact Customer Service at xxxxxxx."
End Try
End Sub
End Class

View 1 Replies

DataSource Controls :: Reading Datetime - Write It To Another Database?

Jun 4, 2010

I have a record created date stored as" 2010-05-16 15:44:18.700" in sql server database. When I read this date it gets converted to "5/16/2010 3:44:18 PM" . How should I read it so that I don't loose the ending '700' value so that it gets written exactly to another database.Code for reading the record:

String myConn = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
SqlConnection con = new SqlConnection(myConn);
SqlCommand cmd = new SqlCommand();[code].....

View 12 Replies

C# - Can Use HashTable For Temporary Data Storage After Reading Data From Database

Feb 5, 2010

I am looking for opinions and best coding practices.I need to get info from a database with a query such as SELECT this, that FROM MyDB (returning 2 fields). Would it be wrong to use a hashtable for temporary storage?Is there a better way to accomplish the same thing? What about if I am returning more than 2 fields, would it be best to step up to a DataSet or something?

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
GetData();
[code]...

View 7 Replies

Forms Data Controls :: Button In GridView - OnClientClick Versus CommandName Postback

Oct 20, 2010

I have a GridView with a couple of buttons (asp:Button) in it (last row). Both of them have a CommandName attribute on them and this is handled server side in a grid_RowCommand event handler. Now, this works fine. However, I need to add client side code (Javascript/jQuery) to disable the two buttons when someone clicks on or the other. This is to prevent the user from double-clicking and creating potential havoc.

The way I have done this is by adding OnClientClick on both buttons which calls a javascript function that uses jQuery to disable the two buttons. This works fine, it's just that the page doesn't post back and so the RowCommand event handler never fires.

[code]....

View 2 Replies

Forms Data Controls :: Insert New Blank Rows In A Gridview And Insert Them In Database Multiple At A Time?

Oct 19, 2010

I have grid view in ASP.Net 3.5. I need to add multiple blank rows in a gridview and then have to save them in database. How can I do that in most simplest way?

View 7 Replies

Forms Data Controls :: Time Used As "amount Of Time Available", Not Time On A Clock?

Jul 6, 2010

how to suppress the "AM" in the gridview (template Bind("RideTimeMin", "{0:t}")? Don't tell me to use military time because the function is not "time on a clock"; it's how much time is allowed for a task (in this case the min/max hours & minutes that horses have to complete a 20 mile trail; e.g. 05:00, 05:27, etc). I'm currently accomplishing this in the "ondatabound" function by "..RTmin.Replace("AM","")". I have looked and looked at all the websites that talk about datetime formatting but have yet to find a way to do it upfront in the gridview bind statement.

View 6 Replies







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