Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Edit MS Access database using VB2010


Edit MS Access database using VB2010

Author
Message
blueye89
blueye89
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 7, Visits: 15
Hi there. Can someone help me to make an simple application presented on attached image . For a two weeks, I tried to make it but no result Sad. I do nothing. I am disappointed because I do not have any knowledge how to do this. Only thing what I know to do is to connect vb and access.





On first look to the picture, you will know what I want to do.

Thanks
zeroGiven
zeroGiven
Forum God
Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)Forum God (684 reputation)

Group: Forum Members
Posts: 2, Visits: 9
I'm assuming from the items in the list that you have populated that list from data in your database.



So one of the ways is to use SQL to perform the various INSERT (add), UPDATE (edit) and DELETE tasks.



This will require an understanding of Structured Query Language.



The basics of performing any of the 3 is a few simple lines of code.



'Instantiate a connection object

Dim con as New OledbConnection ("connection string to your database")



'Create a string to hold your SQL command

Dim sSQL as String = "INSERT INTO myTable (Field1, Field2) VALUES ('Value1', 'Value2')"

'This example would insert a new row into a table in your database named myTable and in that row, the columns named Field1 and Field2 would be populated with the words Value1 and Value2 respectively.



'To execute this statement, we need to do 3 things. 1. Build a command, 2. Open the connection and 3. Execute that command

'Instantiate a command object and pass it two arguments, The statement and the connection.

Dim cmd As New OledbCommand(sSQL, con)

'Open the connection

con.Open

'Execute the command

cmd.ExecuteNonQuery

con.Close




To minimize confusion, as I don't know your level of expertise, I have left out any Try...Catch error handling which I recommend using. Just wanting to keep this simple



Now with that code above, you can perform the other 2 commands (update and delete) just by putting the proper SQL statement in the sSQL string.



All the other code will work for any of those 3 commands.



Keep in mind that the code above assumes that you have also imported the System.Data.OleDb namespace.











How2Prog
How2Prog
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Hi blueye89 !



Take a look at this application, it's similar to your project:



http://how2prog.com/Downloads/Add,%20Edit,%20Delete%20and%20retrieve%20data%20From%20Access.rar





It's designed with MS Visual studio 2012, so if you need a recent version contact me !



=====================================

http://www.how2prog.com



How2Prog.Com Is a wonderful space to learn programming easily, includes many of the open source projects in many different programming languages (Visual Basic.Net, C#.Net, Java EE, ...)
Edited
3/23/2013 by How2Prog
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search