By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Update Access Database from Textbox

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.