conn.open asp.net

  • Thread starter Thread starter amitbadgi
  • Start date Start date
A

amitbadgi

Hi I am converting an asp application to asp.net, and I have an access
database, now when I am running the converted asp.net application in a
browser, I am getting the following error, I am new in this field,
hence need help, thanx in advance

[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException:
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified

Source Error:

Line 10: db_p = db_UP.GetPASS_CC_1()
Line 11: db_dsn = db_UP.getDSN_CC_1()
Line 12: conn.Open (db_dsn, db_u, db_p)
Line 13: 'response.Write(db_dsn&" "& db_u&" "& db_p & "<br>")
Line 14:
 
It looks like you aren't using the command object's properties to get into
the database.

Did you set the properties of your connection object the "ado.net" way?
ie:

Public Sub CreateMyOleDbCommand()
Dim mySelectQuery As String = _
"SELECT * FROM Categories ORDER BY CategoryID"
Dim myCommand As New OleDbCommand(mySelectQuery)
myCommand.Connection = New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=NWIND_RW.MDB")
myCommand.CommandTimeout = 20
End Sub

By the way, that example code (from the sdk) is a crappy example since it
has a hardcoded connection string. An advantage of ASP.net is that you can
store connection strings in the web.config file (one central place) and then
retreive them by doing this: AppSettings("ConnString")
 
Back
Top