VB.net MS Access connection string

Discussion in 'OT Technology' started by morgue, Jun 30, 2006.

  1. morgue

    morgue New Member

    Joined:
    Jul 10, 2004
    Messages:
    8,278
    Likes Received:
    0
    I got this

    Code:
    Imports System.Data.OleDb
    Partial Class Default2
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=u:\testdb.mdb;User Id=admin;Password=;"
            Dim oleConn As New OleDbConnection(connStr)
            oleConn.Open()
            Dim cmdText As String = "select * from TestTable"
            Dim cmd As New OleDbCommand(cmdText, oleConn)
            Dim dr As OleDbDataReader
            dr = cmd.ExecuteReader()
            While dr.Read
                Label1.Text = dr.GetValue(dr.GetOrdinal("dbName"))
            End While
    
            Dim cmd2 As New OleDbCommand(cmdText, oleConn)
            GridView1.DataSource = cmd2.ExecuteReader
            GridView1.DataBind()
        End Sub
    End Class
    

    What I want to know is if I can have an URL as the Source, something like
    Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://www.offtopic.com/testdb.mdb;User Id=admin;Password=;"
     
  2. hsmith

    hsmith OT Supporter

    Joined:
    Feb 24, 2002
    Messages:
    124,533
    Likes Received:
    596
    Location:
    Your mother.
  3. morgue

    morgue New Member

    Joined:
    Jul 10, 2004
    Messages:
    8,278
    Likes Received:
    0
    I searched on that site before posting, couldn't find it.
     
  4. Chaotic Reality

    Chaotic Reality New Member

    Joined:
    Jun 22, 2004
    Messages:
    29,052
    Likes Received:
    0
    Location:
    Phoenix, AZ
    The solution is to not use an Access database. You're welcome.
     
  5. morgue

    morgue New Member

    Joined:
    Jul 10, 2004
    Messages:
    8,278
    Likes Received:
    0
    Really? A Database in access can't be accessed remotely?
     
  6. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    not from a web location. You can put an Access database on a share (for instance) and have multiple people access it, but a web server does not allow for writing to files (thank goodness)
     
  7. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    set yourself up a remote MySQL or MSDE database. Access sucks for everything except a local app db. (and even that is argueable)
     
  8. EvilSS

    EvilSS New Member

    Joined:
    Jun 11, 2003
    Messages:
    5,104
    Likes Received:
    0
    Location:
    STL
    Yea, use MySQL or MSDE or some other real database. If multiple users are going to be using the DB Access can quickly become a headache. If you want to do this across the internet (vs local network) you will probably want to write a web service to sit between your datasource and your app to protect your database.


    On a side note you can reuse your OleDbCommand object. You don't have to create another instance. Be sure to close your reader and connection when you are done with them too.
     
  9. hsmith

    hsmith OT Supporter

    Joined:
    Feb 24, 2002
    Messages:
    124,533
    Likes Received:
    596
    Location:
    Your mother.
    why the hell would you want to write a web service between the app and the db :hsugh:
     
  10. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    i wouldn't do anything over the net anyways, but having a webservice would allow you to not expose the whole database as an open service.
     
    Last edited: Jul 1, 2006
  11. EvilSS

    EvilSS New Member

    Joined:
    Jun 11, 2003
    Messages:
    5,104
    Likes Received:
    0
    Location:
    STL
    To reduce attack surface area. Note I said "If you want to do this across the internet" right before that? Hanging a database server directly on the internet is a surefire way to have it compromised.
     
  12. morgue

    morgue New Member

    Joined:
    Jul 10, 2004
    Messages:
    8,278
    Likes Received:
    0
    Is MySQL a lot easier than SPQ Server?
     
  13. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    I assume you mean SQL Server? Installation is pretty easy with either database, and programming is just "different" syntax wise. MySQL is free.

    EDIT: Free for non-commercial use. Otherwise it's cheaper than crap.
     
  14. morgue

    morgue New Member

    Joined:
    Jul 10, 2004
    Messages:
    8,278
    Likes Received:
    0
    How did I go from L to Q? :rofl:
     

Share This Page