I hope someone can help me with the problem I am having, I get the following error:
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied
I am trying to connect to my SQLServer 2000 db via asp.net. The aspx file uses a DataGrid, the aspx.vbcode behind file gets the connection string from the web.config file. Itested my connection via ODBC, or SQL Query Analyzer just fine so Iknow the userid/password is correct.
this is the snipplet code from the aspx.vb code-behind file:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim dbConn As OleDbConnection
Dim dCmd As OleDbCommand
Dim dReader As OleDbDataReader
Dim strConnection As String
Dim strSQL As String
If (Not Page.IsPostBack) Then
Try
'get the connection string from web.config and open a connection
'to the database
strConnection = ConfigurationSettings.AppSettings("dbConnectionString")
dbConn = New OleDb.OleDbConnection(strConnection)
dbConn.Open()
'build the query string and get the data from the database
strSQL = "SELECT Title, ISBN, Publisher " & _
"FROM Book " & _
"ORDER BY Title"
dCmd = New OleDbCommand(strSQL, dbConn)
dReader = dCmd.ExecuteReader()
'set the source of the data for the datagrid control and bind it
dgQuick.DataSource = dReader
dgQuick.DataBind()
Finally
'cleanup
If (Not IsNothing(dReader)) Then
dReader.Close()
End If
If (Not IsNothing(dbConn)) Then
dbConn.Close()
End If
End Try
End If
End Sub 'Page_Load
End Class
this is the connection string inside the web.config file:
<!--add key="dbConnectionString"value="Provider=SQLOLEDB;Data Source=localhost;InitialCatalog=myDBName;UID=myUserID;PWD=myUserPssd" /-->
<!--addkey="sqlConnectionString" value="Data Source=localhost;InitialCatalog=myDBName;UID=myUserID;PWD=myUserPssd;persist securityinfo=False;" /-->
thanks,
arlena
Try these urls, it is permissions related see if your database setup meets what is in that site in PUBs. I see you are using OLEDB instead of ADO.NET, OLEDB is for none SQL Server and DTS packages. Hope this helps.
http://duhnetnuke2.net/Default.aspx?tabid=64
http://duhnetnuke.net/DesktopDefault.aspx?tabid=40
No comments:
Post a Comment