...

View Full Version : Connecting to a Database.



jammyb
03-27-2013, 03:28 PM
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.

DanInMa
03-27-2013, 07:22 PM
http://www.youtube.com/watch?v=X4yp2_wfGO0
http://msdn.microsoft.com/en-us/library/ms171893(v=vs.100).aspx

jammyb
04-03-2013, 07:12 PM
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?

annaharris
04-04-2013, 02:13 PM
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

livetecshosting
04-06-2013, 10:13 AM
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

annaharris
05-03-2013, 01:52 PM
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.

annaharris
05-08-2013, 02:13 PM
Have you tried to use Sql Server Express Edition which comes along with Visual Studio 2010 ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum