CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 10/24/2009 5:33:44 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 0 Views: 3 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
"john6630" <>
NewsGroup User
Working with Access in the App_Data directory10/24/2009 5:33:44 PM

0

I have an Access database which I created in the App_Data directory. I added the following to the Web.Config file:

<connectionStrings>
        <add name="LWAAccessConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;DataSource==|DataDirectory|\LWA.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>
</connectionStrings>

I create the connection as follows (credit to www.moretechtips.net for the following data access code):

Public Sub Init()
        If ConnString = "" Then
            ConnString = ConfigurationManager.ConnectionStrings(ConnStringID).ConnectionString
            Provider = ConfigurationManager.ConnectionStrings(ConnStringID).ProviderName
        End If
        If Conn Is Nothing Then
            PFactory = DbProviderFactories.GetFactory(Provider)
            Conn = PFactory.CreateConnection
            Conn.ConnectionString = ConnString
            Cmd = PFactory.CreateCommand
            Cmd.Connection = Conn
        End If
    End Sub

If I break execution and look at ConnString at this point I see the exact string from the Web.Config file. The "|DataDirectory|" has not been replaced by the actual path to the database. That may be ok, I do not know.

I try to access the database with this code:

Public Function ExecuteNonQuery() As Integer
        Dim rows As Integer
        Conn.Open()
        rows = Cmd.ExecuteNonQuery()
        Conn.Close()
        Return rows
    End Function

At the "Conn.Open()" command I get the following error:

"Can not find installable ISAM".

I am sure I am missing something simple but do not know where to begin. I added a reference to System.Data to my project but that had not affect.

Any help greatly appreciated.

TIA

John

"john6630" <>
NewsGroup User
Re: Working with Access in the App_Data directory10/25/2009 12:24:37 AM

0

I found the problem. DataSource must be Data Source with a space between the words. Ialso set the Persist Security Info = False. I do not know what that means but it works.

John

"Thomas Sun – M
NewsGroup User
Re: Working with Access in the App_Data directory10/29/2009 7:58:33 AM

0

Hi,

The "Data Source" is the key word.

For more information about connection string to Access, see http://www.connectionstrings.com/access

 

Thanks.


Thomas Sun
Microsoft Online Community Support

Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question.
3 Items, 1 Pages 1 |< << Go >> >|




   
  Privacy | Contact Us
All Times Are GMT