11 Replies - 33123 Views - Last Post: 23 July 2009 - 09:26 AM Rate Topic: -----

#1 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

connect to access database 2007

Post icon  Posted 24 August 2008 - 10:04 AM

Im new to VB.net. Currently im using visual studio 2008 to make a member registration form and i need to save all data into my access database 2007.

Public Class register
Dim datatb As New DataTable
Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\KDE.accdb"
Dim sqlstr As String = "SELECT * FROM"

Private Sub register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Dim dataadp As New OleDb.OleDbDataAdapter(sqlstr, constr)
		dataadp.Fill(datatb)
		dataadp.Dispose()
End Sub

Private Sub butsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butsubmit.Click
		Dim newconnection As New OleDb.OleDbConnection(constr)
		Dim addstr As String = "INSERT INTO `Member` (`Mem-Surname`, `Mem-Name`, `Mem-Address`, `Mem-Postcode`, `Mem-City`, `Mem-Handphone`, `Mem-Since` `Expired-Date`) VALUES (add1, add2, add3, add4, add5, add6, add7, add8)"
		Dim addnewcommand As New OleDb.OleDbCommand

		addnewcommand.Connection = newconnection
		addnewcommand.CommandText = addstr

		addnewcommand.Parameters.AddWithValue("add1", MemSurname.Text)
		addnewcommand.Parameters.AddWithValue("add2", MemName.Text)
		addnewcommand.Parameters.AddWithValue("add3", MemAddress.Text)
		addnewcommand.Parameters.AddWithValue("add4", MemPostcode.Text)
		addnewcommand.Parameters.AddWithValue("add5", MemCity.Text)
		addnewcommand.Parameters.AddWithValue("add6", MemHandphone.Text)
		addnewcommand.Parameters.AddWithValue("add7", MemSince.Text)
		addnewcommand.Parameters.AddWithValue("add8", ExpDate.Text)

		newconnection.Open()
		addnewcommand.ExecuteNonQuery()
		newconnection.Close()

		MsgBox("Account Created Successful")

		modandreg.Show()
		Me.Close()
	End Sub
End Class



This is how i connect to my database. But After i entered all data and click my submit button, the newconnection.open() show out a error. The system said "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."
How to fix the problem?

(sorry if having any broken english :P )

Is This A Good Question/Topic? 0
  • +

Replies To: connect to access database 2007

#2 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 26 August 2008 - 07:34 PM

is there any wrong with me??
i posted my problem so many days, why dont even have 1 people come in and help me??
WTF !!!
Was This Post Helpful? 0
  • +
  • -

#3 hemo  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 70
  • Joined: 02-January 07

Re: connect to access database 2007

Posted 27 August 2008 - 08:03 AM

Which windows os are you running, is it vista 64bit?
Was This Post Helpful? 0
  • +
  • -

#4 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 27 August 2008 - 08:10 PM

yes... im using vista 64bit
Was This Post Helpful? 0
  • +
  • -

#5 Damage  Icon User is offline

  • Lord of Schwing
  • member icon

Reputation: 39
  • View blog
  • Posts: 1,107
  • Joined: 05-June 08

Re: connect to access database 2007

Posted 27 August 2008 - 08:42 PM

A lot of times if you google something you come up with some decent leads. Have a look at

http://www.clariusco...1/15/41639.aspx

I think you'll find your answer there
Was This Post Helpful? 0
  • +
  • -

#6 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 27 August 2008 - 10:10 PM

thanks..the website u gave were useful but i cant find configuration manager to change platform in visual studio 2008
I run my friend app with same provider, its work!
Was This Post Helpful? 0
  • +
  • -

#7 hemo  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 70
  • Joined: 02-January 07

Re: connect to access database 2007

Posted 28 August 2008 - 04:05 AM

You need to alter the Target CUP. Click Project in menu bar > click compile > click advance compile options > drop target CUP and select x86 > click OK.
hemo
Was This Post Helpful? 1

#8 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 28 August 2008 - 11:47 PM

My project menu bar dont have any compile function. :blink:
Here my print screen:
Posted Image
Was This Post Helpful? 0
  • +
  • -

#9 hemo  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 70
  • Joined: 02-January 07

Re: connect to access database 2007

Posted 29 August 2008 - 03:21 AM

Sorry I omitted one step, click properties from the dropdown list.
In your case 'KDEMS Properties' then follow the previous sequence.

hemo
Was This Post Helpful? 1
  • +
  • -

#10 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 01 September 2008 - 08:30 PM

thanks, its working.
And now, my program show a data type error.
is this error from below code?

		addnewcommand.Parameters.AddWithValue("add1", MemSurname.Text)
		addnewcommand.Parameters.AddWithValue("add2", MemName.Text)
		addnewcommand.Parameters.AddWithValue("add3", MemAddress.Text)
		addnewcommand.Parameters.AddWithValue("add4", MemPostcode.Text)
		addnewcommand.Parameters.AddWithValue("add5", MemCity.Text)
		addnewcommand.Parameters.AddWithValue("add6", MemHandphone.Text)
		addnewcommand.Parameters.AddWithValue("add7", MemSince.Text)
		addnewcommand.Parameters.AddWithValue("add8", ExpDate.Text)


This post has been edited by alph87: 01 September 2008 - 08:32 PM

Was This Post Helpful? 0
  • +
  • -

#11 alph87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 08

Re: connect to access database 2007

Posted 03 September 2008 - 06:26 AM

data type problem i fixed.
hemo, i want to ask you.
why after i register a new account into my database, i cant see that account without reopen my system.
anyone can help?
Was This Post Helpful? 0
  • +
  • -

#12 khairiz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-July 09

Re: connect to access database 2007

Posted 23 July 2009 - 09:26 AM

i have try your coding, and got the some problem, and i have already alter your code, the result is ok, can connect to database
and input have in database.


Imports System.Data.OleDb

Public Class register
Dim datatb As New DataTable
Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\member.accdb"
Dim sqlstr As String = "SELECT * FROM tablemember"

Private Sub register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim dataadp As OleDb.OleDbDataAdapter
dataadp = New OleDb.OleDbDataAdapter(sqlstr, constr)
dataadp.Fill(datatb)
dataadp.Dispose()


End Sub

Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click
Dim newconnection As New OleDb.OleDbConnection(constr)
Dim addstr As String = "INSERT INTO `tablemember` (`FirstName`, `LastName`,`Address`,`Zip`,`City`,`Country`) VALUES (add1, add2, add3, add4, add5, add6)"
Dim addnewcommand As New OleDb.OleDbCommand

addnewcommand.Connection = newconnection
addnewcommand.CommandText = addstr

addnewcommand.Parameters.AddWithValue("add1", TextBoxFirstName.Text)
addnewcommand.Parameters.AddWithValue("add2", TextBoxLastName.Text)
addnewcommand.Parameters.AddWithValue("add3", TextBoxAddress.Text)
addnewcommand.Parameters.AddWithValue("add4", TextBoxZipCode.Text)
addnewcommand.Parameters.AddWithValue("add5", TextBoxCity.Text)
addnewcommand.Parameters.AddWithValue("add6", TextBoxCountry.Text)

newconnection.Open()
addnewcommand.ExecuteNonQuery()
newconnection.Close()

MsgBox("Account Created Successful")

'modandreg.Show()
Me.Close()
End Sub
End Class
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1