.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 15th, 2005, 07:04 PM
milanvla milanvla is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 21 milanvla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 25 sec
Reputation Power: 0
asp.net, c#, ms access; where's the problem?

Hello guys

I have litle problem when trying to load data into datagrid from ms access database,

here is code of index.aspx:
Code:
<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="Nable_Soft.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<asp:datagrid id="DataGrid1" runat="server" PageSize="3" AllowPaging="True" AutoGenerateColumns="False"
				AllowSorting="True" BackColor="#E0E0E0" BorderColor="Black" BorderStyle="Dashed" Font-Names="Arial"
				AllowCustomPaging="True">
				<Columns>
					<asp:BoundColumn DataField="lastname" SortExpression="FName" HeaderText="First Name"></asp:BoundColumn>
					<asp:BoundColumn DataField="firstname" SortExpression="LName" HeaderText="Last Name"></asp:BoundColumn>
				</Columns>
			</asp:datagrid></form>
	</body>
</HTML>


and this is the code of behind page index.aspx.cs:
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Nable_Soft
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		public OleDbConnection	  con;
		public OleDbDataAdapter	  dAdapter;
		public DataSet			  dSet;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;		
		public string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data.mdb";
		public string SQL;

		private void InitializeComponent()
		{

		}
		
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			con =new OleDbConnection(conString);  	
	
			SQL = "UPDATE people SET FName = 'asd' , LName = 'wrwerwer'";
			OleDbCommand cmd = new OleDbCommand(SQL,con);
			con.Open();
			cmd.ExecuteNonQuery();

			dAdapter = new OleDbDataAdapter();
		
			dAdapter.SelectCommand = new OleDbCommand("select FName,LName from people", con);
			dSet=new DataSet(); 
			
			//refreshes rows in the DataSet 			
			dAdapter.Fill(dSet);
			DataGrid1.DataSource = dSet;	 
	        DataGrid1.DataMember = "people";
	        DataGrid1.DataBind();	
		
			con.Close();
		}
	}
}

any help?
thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > asp.net, c#, ms access; where's the problem?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT