Connection String Failing.
-
OK this one has me stuck In the below code I am pointing to a Access DB in the App_Data folder in the root of my web site. When I run the code it errors telling me that the dbo.mdb if not in "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" If I rename my "ShowroomRegDB" Access Db to dbo.mdb and copy to the path it is looking all is fine???? Why is it not using the connection path I have placed in the Connection String??? Please help.....
Dim strConn As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/ShowroomRegDb.mdb")) Dim oleConn As New OleDbConnection(strConn) Dim oleComm As New OleDb.OleDbCommand oleComm.Connection = oleConn Try oleConn.Open() oleComm.CommandText = ("SELECT Important FROM dbo.ConfigTb WHERE ConfigID = 1") Dim Important As String = Convert.ToString(oleComm.ExecuteScalar()) oleComm.CommandText = ("SELECT COUNT(*) FROM dbo.IssueTb WHERE Closed = FALSE") Dim count As Integer = Convert.ToInt32(oleComm.ExecuteScalar()) oleComm.CommandText = ("SELECT COUNT(*) FROM dbo.SuggestionTb WHERE SugClosed = FALSE") Dim count1 As Integer = Convert.ToInt32(oleComm.ExecuteScalar()) oleConn.Close() labIssueNumber.Text = count.ToString labSugNum.Text = count1.ToString labImportant.Text = Important.ToString Catch ex As OleDbException labError.Text = ex.Message End Try
When people make you see red, be thankful your not colour blind.
-
OK this one has me stuck In the below code I am pointing to a Access DB in the App_Data folder in the root of my web site. When I run the code it errors telling me that the dbo.mdb if not in "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" If I rename my "ShowroomRegDB" Access Db to dbo.mdb and copy to the path it is looking all is fine???? Why is it not using the connection path I have placed in the Connection String??? Please help.....
Dim strConn As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/ShowroomRegDb.mdb")) Dim oleConn As New OleDbConnection(strConn) Dim oleComm As New OleDb.OleDbCommand oleComm.Connection = oleConn Try oleConn.Open() oleComm.CommandText = ("SELECT Important FROM dbo.ConfigTb WHERE ConfigID = 1") Dim Important As String = Convert.ToString(oleComm.ExecuteScalar()) oleComm.CommandText = ("SELECT COUNT(*) FROM dbo.IssueTb WHERE Closed = FALSE") Dim count As Integer = Convert.ToInt32(oleComm.ExecuteScalar()) oleComm.CommandText = ("SELECT COUNT(*) FROM dbo.SuggestionTb WHERE SugClosed = FALSE") Dim count1 As Integer = Convert.ToInt32(oleComm.ExecuteScalar()) oleConn.Close() labIssueNumber.Text = count.ToString labSugNum.Text = count1.ToString labImportant.Text = Important.ToString Catch ex As OleDbException labError.Text = ex.Message End Try
When people make you see red, be thankful your not colour blind.
Try adding a "/" to the beginning of your connection string Dim strConn As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/App_Data/ShowroomRegDb.mdb")) This tells the webserver to look in the root of your webfolder.
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't
-
Try adding a "/" to the beginning of your connection string Dim strConn As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/App_Data/ShowroomRegDb.mdb")) This tells the webserver to look in the root of your webfolder.
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't
No Good It also fails if i put the absolute path "C:\Inetpub\wwwroot\ShowroomRegister\App_Data\ShowroomRegDB" Very Strange... I know the Connection string works but it keeps looking for dbo.mdb for some reason. I'm stumped.
When people make you see red, be thankful your not colour blind.
-
No Good It also fails if i put the absolute path "C:\Inetpub\wwwroot\ShowroomRegister\App_Data\ShowroomRegDB" Very Strange... I know the Connection string works but it keeps looking for dbo.mdb for some reason. I'm stumped.
When people make you see red, be thankful your not colour blind.
Try altering your SQL commands from ("SELECT Important FROM dbo.ConfigTb WHERE ConfigID = 1") to: ("SELECT Important FROM ConfigTb WHERE ConfigID = 1") I think the "dbo" - may be confusing the Driver.
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't