Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 April 9th, 2005, 02:45 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in OleDBConnection : Object reference not se

I am running the following code in .Net with MS Access. It executes when the value of variable i is 1 and when the loop continues and value of i becomes 2 i am getting error "Object reference not set to an instance of an object" in the cmdSearch.CommandText line in the code. . There is no problem with connection string. It successfully retrieves when i = 1. Can anybody help me out what is the problem. Please post with corrected code if anybody can help.
===========================================
for (int i=1; i <= objFolder.Items.Count; i++)
{
System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection();
System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand();
odbSearch.ConnectionString = strConn;
cmdSearch.Connection = odbSearch;
item = (Outlook.ContactItem) objFolder.Items.Item(i);
string em = item.Email1Address;
cmdSearch.CommandText = "select * from Outlook_Contacts where FirstName='"+fn.ToString().Trim()+"' and LastName='"+ln.ToString().Trim()+"'";
odbSearch.Open();
OleDbDataReader rdrSearch = cmdSearch.ExecuteReader();
while( rdrSearch.Read())
{
RecordFlag = true;
}
odbSearch.Close();
}
===========================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
ReportViewer runtime error:Object reference not se gobotsoup Classic ASP Databases 0 March 13th, 2007 04:37 PM
Class Object reference error. mjhoagland ASP.NET 1.0 and 1.1 Basics 2 February 2nd, 2006 09:28 AM
Getting Error - "Object reference not set to an in peri C# 2 December 24th, 2004 11:20 AM
Object reference Error mrideout BOOK: Beginning ASP.NET 1.0 4 August 9th, 2004 07:29 AM
Object reference error shaileshmark SQL Server 2000 2 July 22nd, 2004 03:13 PM





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