Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 April 6th, 2007, 05:45 PM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Problem with DataTable

I have this code in Data Access Layer which is called by Application but its not returning any value from table, cant able to figure out where problem is.... any idea , comment will be appretiated

file..... webconfig

<configuration>
  <appSettings>
    <add key="DB"
         value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\db.mdb;Jet OLEDB:Database Locking Mode=1;Mode=16" />
  </appSettings>
    <connectionStrings />


file..... DAL.cs

public class DAL
{
    private String _ConnectionString;
    private OleDbCommand _SqlCommand;
    private OleDbConnection _Connection;
    private OleDbDataAdapter _SqlDataAdapter;
    private DataTable _ProductSearchResultTable;

    public DAL()
    {
        // todo:
    }

    public string ConnectionString()
    {
        _ConnectionString = ConfigurationManager.AppSettings["PlatinumDiamondDB"];
        _Connection = new OleDbConnection(_ConnectionString);
        return _ConnectionString ;
    }

    public DataTable SeacrhProduct(string shape, string miniPrice, string maxPrice)
    {

        _SqlCommand = new OleDbCommand();
        _SqlCommand.CommandText = "select * from product ";//where productprice between '" + miniPrice + "' AND '" + maxPrice +"'";
        _SqlCommand.Connection = _Connection;
        _SqlDataAdapter = new OleDbDataAdapter(_SqlCommand);
        _ProductSearchResultTable = new DataTable("ProductTable");
        _SqlDataAdapter.Fill(_ProductSearchResultTable);
        _Connection.Close();
        _SqlDataAdapter.Dispose();
        _Connection.Dispose();
    return _ProductSearchResultTable;
}


 
Old April 8th, 2007, 10:12 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It would appear the problem is that you aren't using the same key name for the config and code.

Here's what you have in the config file:
Code:
<add key="DB" value="Provider=Microsoft.Jet.OLEDB.4.0;
   Data Source=D:\My Documents\db.mdb;Jet OLEDB:Database Locking Mode=1;Mode=16" />

Here's what you have in the code:
Code:
_ConnectionString = ConfigurationManager.AppSettings["PlatinumDiamondDB"];
Those need to match.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable AutoincrementColumn problem Jayaram ASP.NET 2.0 Professional 0 December 5th, 2006 03:20 AM
For Loop problem with DataSet\DataTable musa BOOK: ASP.NET Website Programming Problem-Design-Solution 2 December 25th, 2003 03:11 AM
For Loop problem with DataSet\DataTable musa BOOK: Professional C#, 2nd and 3rd Editions 1 December 24th, 2003 09:46 AM
For Loop problem with DataSet\DataTable musa BOOK: Beginning ASP.NET 1.0 0 December 23rd, 2003 06:31 PM
updating db with dataAdapter/dataTable problem mm1234 ADO.NET 0 November 19th, 2003 06:49 AM





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