PDA

View Full Version : *Resolved* Web Config Appsettings Connection


Neil Newman
03-08-2004, 01:20 AM
Hi
I am testing connection with access db with not much success. In VS IDE everything works but running live the connection does not make eg.

Web config
<appSettings>
<add key ="ConnectionString" value="Provider=Microsoft.jet.oledb.4.0;Data Source=\password.mdb" />
</appSettings>

Code Behind
Public Function ValidateUser(ByVal UID As String, ByVal PWD As String) As Boolean

Dim OLEConn As New OleDb.OleDbConnection()
OLEConn.ConnectionString = ConfigurationSettings.AppSettings("connectionstring")
Dim strSQL As String = "Select Username, password from tblLoginID"
Dim OLECmd As New OleDb.OleDbCommand(strSQL, OLEConn)
Dim OLEdr As OleDb.OleDbDataReader
Try
OLEConn.Open()
OLEdr = OLECmd.ExecuteReader()
Do While OLEdr.Read
If LCase(OLEdr("Username")).ToString = UID And LCase(OLEdr("password")).ToString = PWD Then
Return True
Exit Function
End If
Loop
Catch EX As Exception
Return False
End Try
Return False
End Function

Thankyou for time

Neil

Resolved i needed the server path of the database directory.

bruce
03-09-2004, 02:36 AM
You can find the root path to your site in the account information section in the control panel.
[b]quote:Originally posted by Neil Newman

Hi
I am testing connection with access db with not much success. In VS IDE everything works but running live the connection does not make eg.

Web config
<appSettings>
<add key ="ConnectionString" value="Provider=Microsoft.jet.oledb.4.0;Data Source=\password.mdb" />
</appSettings>

Code Behind
Public Function ValidateUser(ByVal UID As String, ByVal PWD As String) As Boolean

Dim OLEConn As New OleDb.OleDbConnection()
OLEConn.ConnectionString = ConfigurationSettings.AppSettings("connectionstring")
Dim strSQL As String = "Select Username, password from tblLoginID"
Dim OLECmd As New OleDb.OleDbCommand(strSQL, OLEConn)
Dim OLEdr As OleDb.OleDbDataReader
Try
OLEConn.Open()
OLEdr = OLECmd.ExecuteReader()
Do While OLEdr.Read
If LCase(OLEdr("Username")).ToString = UID And LCase(OLEdr("password")).ToString = PWD Then
Return True
Exit Function
End If
Loop
Catch EX As Exception
Return False
End Try
Return False
End Function

Thankyou for time

Neil

Resolved i needed the server path of the database directory.
</blockquote id="quote"></font id="quote">