Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Databases Also see the forum ASP Databases for more general discussions of ASP database issues not directly related to these books.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Databases 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 October 29th, 2003, 05:41 PM
Authorized User
 
Join Date: Oct 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to a SQL data source

Okay chapter 3 first example for some reason will not let me connect to northwind. Error states I have a login error so naturally I said "ah" and went to the Northwind.mdf file and gave ASPNET permissions to use the file, however, I still receive the error. Any help would suffice.

"Is the glass half full, half empty, or twice as large as it needs to be?"
__________________
\"Is the glass half full, half empty, or twice as large as it needs to be?\"
 
Old October 30th, 2003, 12:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

can u post ur ConnectionString?! that should be something like this.
data source=YOUR_SERVER;initial catalog=northwind;password=YOURPASS;persist security info=True;user id=USER_NAME;packet size=4096

Always:),
Hovik Melkomian.
 
Old November 26th, 2003, 01:02 PM
Registered User
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chapter 03 first and second example, although i typed the code exactly the same from book, in both cases, i can only see the heading with <h3>. the rest of the table can't be seen in both examples. Then, I replace the files with the one from download code, the same problem. Is it my connection error or what? I put the code as follows.

First Example

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

<html>
  <head>
    <title>Beginning ASP.NET Databases Using C#: Chapter 3</title>
  </head>

  <body>
    <h4>First Example: Listing data from the Employees table</h4>
    <asp:DataGrid id="dgNameList"
                  runat="server"
                  GridLines="None"
                  BackColor="LightBlue"
                  CellPadding="5"
                  CellSpacing="5"
                  BorderWidth="2"
                  BorderColor="Black"
                  ToolTip="Includes only those employees who are at HQ" />
  </body>
</html>

<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  String strConnection = "server=(local)\\NetSDK; database=Northwind; integrated security=true;";
  SqlConnection objConnection = new SqlConnection(strConnection);

  String strSQL = "SELECT FirstName, LastName, Country " + "FROM Employees";
  SqlCommand objCommand = new SqlCommand(strSQL, objConnection);

  objConnection.Open();
  dgNameList.DataSource = objCommand.ExecuteReader();
  dgNameList.DataBind();
  objConnection.Close();
}
</script>
-----------------------------------------------------------------------------------
Second Example
..............

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.OleDb" %>

<html>
  <head>
    <title>Connecting to an Access Database</title>
  </head>

  <body>
    <H3>Connecting to an Access Database</H3>
    <asp:DataGrid id="dgSuppliers" runat="server" />
  </body>
</html>

<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  String strConnection = "Provider=Microsoft.Jet.OleDb.4.0; data source=C:\\7418BegASPNETdbCS\\datastores\\Northwin d.mdb;";
  OleDbConnection objConnection = new OleDbConnection(strConnection);

  String strSQL = "SELECT SupplierID, CompanyName FROM Suppliers";
  OleDbCommand objCommand = new OleDbCommand(strSQL, objConnection);

  objConnection.Open();
  dgSuppliers.DataSource = objCommand.ExecuteReader();
  dgSuppliers.DataBind();
  objConnection.Close();
}
</script>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Source Tools to generate XML from SQL data ethanhunt XML 0 May 7th, 2008 02:55 PM
Data connecting problem zzw_typ BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 May 30th, 2007 06:50 AM
C# connecting to SQL Express supertorro C# 0 July 10th, 2006 07:33 AM
Dynamic sql data source MDM ASP.NET 2.0 Professional 3 April 5th, 2006 11:45 PM
data source and SQL queries sss22 ASP.NET 1.0 and 1.1 Basics 1 October 24th, 2005 01:13 PM





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