473,289 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Update Access Database from Textbox

Hi, I just starting using VB.NET and I a few textboxes on a form. I want to enter info into the textboxes, click the Add Button and update my Access database. Can't get it to work. Maybe someone
has a good example for me, thanks.

--------------------------------
From: Shawn Jackson

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Z58bsw+1BUKMhOaY2aYiPQ==</Id>
Nov 21 '05 #1
1 9229
Here is a really simplistic example of one form, one button adding a row.

HTH

Terry Burns

-------------------------------------------

'At class level

Private OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand

Private OleDbConnection1 As System.Data.OleDb.OleDbConnection

Private OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter

'Under a button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand

OleDbConnection1 = New System.Data.OleDb.OleDbConnection

OleDbInsertCommand1.CommandText = "INSERT INTO [Names] (Name) VALUES ('" &
TextBox1.Text & "');"

OleDbInsertCommand1.Connection = Me.OleDbConnection1

OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\TESTTB.mdb;User Id=admin;Password=;"

Try

OleDbConnection1.Open()

OleDbInsertCommand1.ExecuteNonQuery()

Catch ex As OleDb.OleDbException

MessageBox.Show(ex.ToString)

End Try

OleDbConnection1.Close()

End Sub


--
Terry Burns
http://TrainingOn.net

"Shawn Jackson via .NET 247" <an*******@dotnet247.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi, I just starting using VB.NET and I a few textboxes on a form. I want
to enter info into the textboxes, click the Add Button and update my
Access database. Can't get it to work. Maybe someone
has a good example for me, thanks.

--------------------------------
From: Shawn Jackson

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Z58bsw+1BUKMhOaY2aYiPQ==</Id>

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter...
13
by: abdoly | last post by:
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update that is the code private void DataGrid1_UpdateCommand(object source,...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
2
by: Ville Mattila | last post by:
Hi there, I will post my question to this group too bacause the .data group seems to be rather quiet. I've been playing with VB.NET and ADO for a week now and find the different data handling...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
2
by: BOS | last post by:
Hi there, I just create a form that contains name, Address, City, State, Zip, Question Checked box, and dropdown list selection for the user to fill-out the answer in the texbox, checkbox or...
1
by: gomathinayagam | last post by:
hai, am only beginer in c#... i am trying to connect database with webform. using a technique that the fields of the table and the controls in a form are named same...then i try get the controls...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.