User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 397,625 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,454 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3111 | Replies: 10
Join Date: Nov 2005
Posts: 23
Reputation: Reham Ejaz is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Reham Ejaz Reham Ejaz is offline Offline
Newbie Poster

Error connecting to database

  #1  
Jan 15th, 2006
I am having problem in connecting to database. The problem is with the following code.

dim objCmd as new OleDbDataAdapter()
objCmd.SelectCommand.Connection = dbconn
objCmd.SelectCommand.CommandText= sql 


I am having error on line2

the error is

System.NullReferenceException: Object variable or With block variable not set.

I think there is problem in my connection string but i cant figure out.

the connection string is

dim strConnection as String="Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("mydb.mdb")
Dim dbconn as New OleDbConnection(strConnection)

i have also tried

dim dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=c:/inetpub/wwwroot/day1/mydb.mdb")

but still its not working. I have also seen some tutorials but they didnt help me. Can anyone plz tell me what could be wrong. I want to insert values into database from textboxes.
But i am facing this connectivity error.
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 8:56 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC