Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Connecting to a Database.

    Hello Folks.

    I am struggling connecting to an Access Database.
    Basically I am using Visual Studio 2010 and want
    to connect to an Access 2010 Database.
    All I want to do is add the details to the Database such as;
    Forename, Surname, Address, etc

    Once a button is clicked.

    Any help would be much appreciated.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
            Dim conn As New System.Data.OleDb.OleDbConnection()
            Dim cmd As New System.Data.OleDb.OleDbCommand()
    
            conn.ConnectionString = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Jonathan\Desktop\BeechSports.accdb;Persist Security Info=False;"
            cmd.CommandText = "INSERT INTO Register (First_Name)" & _
                      " Values (" & Me.txtFirstName.Text & "')"
            Try
                conn.Open()
                cmd.ExecuteNonQuery()
            Catch ex As Exception
                ' MessageBox.Show("Failed to connect to data source: " & vbLf & ex.Message)
            Finally
                conn.Close()
            End Try
    I have now altered my code but, with no joy.
    Can anybody help please?

  • #4
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    101
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Regarding Database Connection

    Check out the link that I have provided below as it will guide you to establish a database connection.

    http://www.w3schools.com/aspnet/aspnet_dbconnection.asp

  • #5
    New Coder
    Join Date
    Jul 2012
    Location
    Bug Tracking, Isssue Tracking
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Take a look on this article for how to connect to MS Access and other database
    http://www.asp.net/web-forms/tutorials/data-access

  • #6
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    101
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Why do want to use access database while you are using Visual Studio 2010 ? Try SQL Server Express Edition, which is inbuilt in Visual Studio.

  • #7
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    101
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Have you tried to use Sql Server Express Edition which comes along with Visual Studio 2010 ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •