473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.Net VB Access DataTable fill changes connection string

1
Problem:
My project was initially created without putting passwords in the connection string. When I added the password in the connection string, it disappears when performing a database fill. I have stepped through the code in debug and the connection string is correct up til the Fill command. Once the fill executes, the password disappears from the connection string. This particular Fill is performed to check that the user is valid for this database and are able to proceed further in the app.

I see no reason that the password should drop out of the connection string. Does anyone have any suggestions or reasons why this is happening? Any way of making it NOT happen? I know Access is crap. I have assurances that the company will convert to SQL Server and it can't happen soon enough to suit me.

Before executing the fill, the connection string inside dbConnection is
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\database.mdb;User ID=user;Password=password;Jet OLEDB:System database=C:\DB\Security.mdw"
After, it is
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\database.mdb;User ID=user;Jet OLEDB:System database=C:\DB\Security.mdw"

If I put dbConnection in a Session variable before executing the Fill, the value in the Session is changed after the Fill as well.

Relevant Code:
Expand|Select|Wrap|Line Numbers
  1. Public Class Constants
  2.     Public Class ConfigurationKeys
  3.         Public Const CONNECTION_STRING As String = "ConnectionString"
  4. ...
  5. ' Data Source and System Database are derived from which market a user chooses
  6. ' User ID and Password are entered by the user
  7. <connectionStrings>
  8.     <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};User ID={1};Password={3};Jet OLEDB:System database={2}" providerName="System.Data.OleDb"/>
  9. </connectionStrings>
  10. ...
  11.     Public Class SelectCommands
  12.         Public Const TEST_DB_ACCESS As String = "SELECT TOP 1 Table_ID FROM tblTable"
  13. ...
  14.     Dim m_dsMKTs As New DataSet()
  15. ...
  16.  
  17.         Dim currentMKT As New MKTInfo
  18.         Dim iIndex As Integer = ddlMKT.SelectedIndex
  19.         Dim strUserId As String = tbUserID.Text
  20.         Dim strPassword As String = tbPassword.Text
  21.  
  22.         ' If a MKT has been selected, populate the MKTInfo class
  23.         If iIndex > 0 Then
  24.             Dim dtJDE_ID As New DataTable
  25.  
  26.             currentMKT.Name = m_dsMKTs.Tables(0).Rows(iIndex - 1)("Name")
  27.             currentMKT.DatabasePath = m_dsMKTs.Tables(0).Rows(iIndex - 1)("DatabasePath")
  28.             currentMKT.SecurityFile = m_dsMKTs.Tables(0).Rows(iIndex - 1)("SecurityFile")
  29.  
  30.             ' Build the access database connection string based on the MKT specified and current user
  31.             Dim strConnectionFormat As String = ConfigurationManager.ConnectionStrings(Constants.ConfigurationKeys.CONNECTION_STRING).ConnectionString
  32.             Dim strConnectionString As String = String.Format(strConnectionFormat, currentMKT.DatabasePath, strUserId, currentMKT.SecurityFile, strPassword)
  33.             Dim dbConnection As OleDbConnection = New OleDbConnection(strConnectionString)
  34.             Dim strSelectCommand As String = Constants.SelectCommands.TEST_DB_ACCESS
  35.             Dim daJDE_ID As New OleDbDataAdapter(strSelectCommand, dbConnection)
  36.  
  37.             Try
  38.                 daJDE_ID.Fill(dtJDE_ID) ' this is where I have problems.
  39.  
  40.                 'Workaround - have to re-establish the connection string because the previous line removes the password for some reason
  41.                 dbConnection.Close()
  42.                 dbConnection = New OleDbConnection(strConnectionString)
Aug 31 '07 #1
1 2592
add "Persist Security Info=True" to your connection string.
Sep 9 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Job Lot | last post by:
I have written 6 Queries in an Access DB, which are executed in a For Each…Next loop to populate DataSet object. A new DataTable object is created in DataSet for each query, as follows Private...
12
by: VMI | last post by:
For some reason, the process of retrieving data (about 20 records) from an Access table that has 400K records to a dataTable is taking over 3 mins. to complete. Below is my code to connect to the...
1
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
4
by: Hexman | last post by:
I've been trying to figure ADO.net/VB/AccessDB out for some time. I've read many internet articles that have been pointed out to me by people in this group. Thanks for trying to help. I just...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
1
by: Rico | last post by:
I have tried to access a database using asp.net. after some entries like 120+, I got an unspecified error message. Anyone know what is happening, it seems to be stuck at the same line even when i...
17
by: vish | last post by:
Hi all, I know this might look strange at first look, but i am looping thru a dataset created using to different tables from database.These two tables have some fields with the same names. ...
0
by: calvinkwoo3000 | last post by:
My Window application run property withour link to mdb without password. Once i set security password to mdb file, the error belor come out when i click detail. Not a valid password. and detail...
4
by: sarabonn | last post by:
hallo everyone, Iam using access database and visual c# 2008. Iam tried to insert data into table with lot of method but nothing works, i dont know what is wrong. here...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.