vb.net talking to ms access database...

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 6016 Views - Last Post: 08 June 2012 - 02:09 PM Rate Topic: -----

#1 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

vb.net talking to ms access database...

Posted 29 May 2012 - 03:05 PM

I have a form with a richtextbox on it, two textboxes, and a button. My database has 2 rows (username, password) the table name is 'login'.

Now what I want to do is make it so that my rtb reads exactly what the database says, and when I type in a username in the first textbox and a password in the other and press the button, that it will enter the new data accordingly.

I have the database for my username working, and the name is "database2.mdb" so far the login works wonderfully. can you help me please. Hopefully with this answered I can complete my work easier.

Is This A Good Question/Topic? 0
  • +

Replies To: vb.net talking to ms access database...

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: vb.net talking to ms access database...

Posted 29 May 2012 - 05:08 PM

Now what I want to do is make it so that my rtb reads exactly what the database says
what the database says?
I have the database for my username working, and the name is "database2.mdb" so far the login works wonderfully.
so you have two databases? one for username and one for password?
Was This Post Helpful? 0
  • +
  • -

#3 3P1C_F@!l  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 01-March 11

Re: vb.net talking to ms access database...

Posted 30 May 2012 - 08:09 AM

I'm a little fuzzy on what you are trying to achieve here. You want the rich textbox to display the entire table? Or are you wanting to know how to update your database from the username and password textbox controls? If it's the first of the two I would ditch the rich textbox control and go for a DataGridView and read the entire contents of your login table into a dataset for display. If it's the database you want to update you will need to run an INSERT query. Example..

"INSERT INTO login ('username', 'password') VALUES ('" & txtUsername.text & "', '" & txtPassword.text & "');"


Also, things like usernames and passwords should NEVER be stored or transmitted in plain text. Not to mention you're using Access which is terribly slow at doing things like this. You should be using sql (mysql community edition is free).
Was This Post Helpful? 0
  • +
  • -

#4 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

Re: vb.net talking to ms access database...

Posted 30 May 2012 - 02:21 PM

Ok so I have a single database, that holds a password and username combo in a table named login. I want admins to be able to see all the username and password combo's in a rich text box (or another table) I am sorry that I didnt explain that well enough , and thank you all for the timely replies.

Now the other part of this I want is to be able to say I want to add a user named mike and a password named pass into the database by using text box's and the button.
Was This Post Helpful? 0
  • +
  • -

#5 3P1C_F@!l  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 01-March 11

Re: vb.net talking to ms access database...

Posted 30 May 2012 - 02:38 PM

Not to be rude here but you seem to not have even made an attempt on your own at doing this. It's honestly not that complicated and I understand the fact that you may be having trouble with the concept of updating the table with the new data or pulling your query results into a text editor or grid of some sort. However, since you haven't pasted a single line of code it leads me to believe you haven't the slightest of ideas on how to even connect to said database. I would advise you to follow this link and do some reading. Also, as I previously stated I would strongly suggest using some variation of SQL and not Access.
Was This Post Helpful? 0
  • +
  • -

#6 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

Re: vb.net talking to ms access database...

Posted 30 May 2012 - 02:52 PM

here is what I have so far
 Dim Mycn As OleDbConnection
    Dim Command As OleDbCommand
    Dim icount As Integer
    Dim SQLstr As String



Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            Mycn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\users\gaudettemi\desktop\database2.mdb;")
            Mycn.Open()
            SQLstr = "INSERT INTO username,password VALUES('" & Txtusername.Text & "','" & Txtpassword.Text & "')"

            Command = New OleDbCommand(SQLstr, Mycn)
            icount = cmd.ExecuteNonQuery
            MessageBox.Show(icount)

        Catch ex As Exception
            MessageBox.Show("could not insert record")
            Mycn.Close()
        End Try

    End Sub


Was This Post Helpful? 0
  • +
  • -

#7 3P1C_F@!l  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 01-March 11

Re: vb.net talking to ms access database...

Posted 30 May 2012 - 03:16 PM

First, that isn't the INSERT statement I provided you with.. you've managed to take out what you feel you didn't need I guess. Second, txtUsername.text and txtPassword.text should have been changed to your textbox names. Also, that was a very sloppy solution that I provided to your question and wouldn't suggest using it unless you are doing this for homework (I might not even do it then). It was meant to be quick and dirty and give you an idea of what you needed to do. Please take my advice and follow the link I provided to get more complete instructions on how to achieve what it is you are trying to accomplish. You will never get anywhere in the coding world being spoon fed your answers and letting others think for you.
Was This Post Helpful? 0
  • +
  • -

#8 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

Re: vb.net talking to ms access database...

Posted 31 May 2012 - 02:50 PM

Listen, I have only a few things I can use ... ms access and vb.net and I am slightly new to ms.access however not new to vb.net, so stop acting cocky here, I set up the code I wanted it and asked for help, if you cannot help me (as I tried your example) then stop commenting here kk? thanks ps. I am currently incarcerated and looking for help, If I finish this program I get cash.
Was This Post Helpful? 0
  • +
  • -

#9 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: vb.net talking to ms access database...

Posted 31 May 2012 - 03:18 PM

do you get any error from the sample code from the post #6?
Was This Post Helpful? 0
  • +
  • -

#10 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

Re: vb.net talking to ms access database...

Posted 01 June 2012 - 02:12 PM

View Postsela007, on 31 May 2012 - 03:18 PM, said:

do you get any error from the sample code from the post #6?


yes it skips to the last error message instead of inserting the info like I want it to.
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8371
  • View blog
  • Posts: 31,099
  • Joined: 12-June 08

Re: vb.net talking to ms access database...

Posted 01 June 2012 - 02:15 PM

Well.. what does the error say? Put a break point on the catch bit and see what the debug information shows you.
Was This Post Helpful? 0
  • +
  • -

#12 3P1C_F@!l  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 01-March 11

Re: vb.net talking to ms access database...

Posted 01 June 2012 - 02:34 PM

According to what you have previously stated your INSERT statement is wrong and needs to be corrected. If you have a table named "login" with two fields named "username" and "password" your INSERT statement should be EXACTLY like what I provided you with (substituting txtusername.text and txtpassword.text for your textbox control names .text).
Was This Post Helpful? 0
  • +
  • -

#13 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: vb.net talking to ms access database...

Posted 01 June 2012 - 08:57 PM

3P1C_F@!l is right. Your INSERT INTO statement is wrong.
1. learn how to use INSERT INTO statement.
2. if you catch "ex" as exception you can get the error message with ex.message property.
      Catch ex As Exception
            MsgBox(ex.Message)
        End Try

3. if you say you not new to vb.net, than you know about debugging process, otherwise i suggest you to learn how to use debugging.
Was This Post Helpful? 0
  • +
  • -

#14 xXkillpulseXx  Icon User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 25
  • Joined: 10-April 12

Re: vb.net talking to ms access database...

Posted 05 June 2012 - 02:35 PM

All it says is "Object reference not set to an instance of an object" I am taking it that this is an access error seems how I have never run into this in vb.net?
Was This Post Helpful? 0
  • +
  • -

#15 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: vb.net talking to ms access database...

Posted 05 June 2012 - 03:08 PM

This is not access error ,but can be related to. You must tell us where do you get error , in which line? Use debugging or just remove Try/Catch and check in which line is it.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2