Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,408 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,477 people online right now. Registration is fast and FREE... Join Now!




connect to access database 2007

 
Reply to this topicStart new topic

connect to access database 2007

alph87
24 Aug, 2008 - 09:04 AM
Post #1

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
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.

CODE

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 tongue.gif )
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
26 Aug, 2008 - 06:34 PM
Post #2

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
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 !!!
User is offlineProfile CardPM
+Quote Post

hemo
RE: Connect To Access Database 2007
27 Aug, 2008 - 07:03 AM
Post #3

New D.I.C Head
*

Joined: 2 Jan, 2007
Posts: 23



Thanked: 1 times
My Contributions
Which windows os are you running, is it vista 64bit?
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
27 Aug, 2008 - 07:10 PM
Post #4

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
yes... im using vista 64bit
User is offlineProfile CardPM
+Quote Post

Damage
RE: Connect To Access Database 2007
27 Aug, 2008 - 07:42 PM
Post #5

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 738



Thanked: 7 times
Dream Kudos: 75
My Contributions
A lot of times if you google something you come up with some decent leads. Have a look at

http://www.clariusconsulting.net/blogs/kzu...1/15/41639.aspx

I think you'll find your answer there
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
27 Aug, 2008 - 09:10 PM
Post #6

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
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!
User is offlineProfile CardPM
+Quote Post

hemo
RE: Connect To Access Database 2007
28 Aug, 2008 - 03:05 AM
Post #7

New D.I.C Head
*

Joined: 2 Jan, 2007
Posts: 23



Thanked: 1 times
My Contributions
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
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
28 Aug, 2008 - 10:47 PM
Post #8

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
My project menu bar dont have any compile function. blink.gif
Here my print screen:
IPB Image
User is offlineProfile CardPM
+Quote Post

hemo
RE: Connect To Access Database 2007
29 Aug, 2008 - 02:21 AM
Post #9

New D.I.C Head
*

Joined: 2 Jan, 2007
Posts: 23



Thanked: 1 times
My Contributions
Sorry I omitted one step, click properties from the dropdown list.
In your case 'KDEMS Properties' then follow the previous sequence.

hemo
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
1 Sep, 2008 - 07:30 PM
Post #10

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


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

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: 1 Sep, 2008 - 07:32 PM
User is offlineProfile CardPM
+Quote Post

alph87
RE: Connect To Access Database 2007
3 Sep, 2008 - 05:26 AM
Post #11

New D.I.C Head
*

Joined: 24 Aug, 2008
Posts: 7


My Contributions
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?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:18PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month