Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2003, 03:59 AM
Registered User
 
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to RaZorCleaN
Default Connect to DB

I am a Noob on ASP.NET, I am doing a connection to a DB but i dont understand it quite...the mdb file is in the sam folder bu only get a error mess ! do I have to insall a DB, how do I connect to mysql???

Would be super if someone could help me...

Code:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e)
{ 
  OleDbConnection objConnection;
  OleDbDataAdapter objCommand;  
  string strConnect; 
  string strCommand; 
  DataSet DataSet1 = new DataSet();
 
  strConnect =  @"Provider=Microsoft.Jet.OLEDB.4.0;";

folder this sample is from asp.net with c#
  strConnect += @"Data Source=C:\Program Files\Microsoft.NET\FrameworkSDK\";
  strConnect += @"Samples\quickstart\aspplus\samples\grocertogo\data";
  strConnect += @"\grocertogo.mdb;";

  strConnect += "Persist Security Info=False";

  strCommand = "SELECT ProductName, UnitPrice FROM products";
  objConnection = new OleDbConnection(strConnect);
  objCommand = new OleDbDataAdapter(strCommand, objConnection);
  objCommand.Fill(DataSet1, "products");
  DataGrid1.DataSource=DataSet1.Tables["Products"].DefaultView;
  DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"  />
</body>
</html>
//RaZ
www.razorclean.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
need guideline about connect to DB Jose P ADO.NET 2 May 9th, 2007 11:57 AM
How to connect to DB rtr1900 VB Databases Basics 4 December 5th, 2006 03:36 PM
Connect to DB hernann C# 2005 2 July 31st, 2006 05:06 PM
Connect two or more DB at the same time?? rtr1900 Classic ASP Databases 0 May 31st, 2006 06:32 AM
connect to sql db jopay Visual C++ 0 January 12th, 2005 05:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.