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.