Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Reply
Error in OleDBConnection : Object reference not set to an instance of an object
sunil
Apr 9 2005 2:50 AM
2.2k
Reply
I am running the following code. 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(); } ======================================================
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
DirectoryEntry and comma in LDAP path
How can I make a collection of 2 dimensional arrays?