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

updating a database through a visual basic form

P: 1
Hi
i need to update a database which is connected to a form in visual basic.
the entries that made in text boxes present in the form must be updated to the connected database.
Can u help me with a sample code..

thanks,
Jul 26 '08 #1
Share this Question
Share on Google+
3 Replies


smartchap
100+
P: 236
Using ADO and its update method u can update the data written in textboxes or a grid etc in a form. For updating u can place a command button on form which is clicked after all fields / controls on the form are filled as required.
Jul 26 '08 #2

P: 1
<QUOTE>
Ms Access
using ADO you can write the following code
Public dbase As New ADODB.Connection
Public rsconn As New ADODB.Recordset
Set dbase = New ADODB.Connection
dbase.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\databaseName.mdb"
Set rsconn = New ADODB.Recordset
Set rsconn = dbase.Execute("UPDATE tableName SET field1 = '" & txtfieldName.Text &"' WHERE keyField = '" & txtkeyField.Text & "'")

With rsconn
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Source = "select * from ItableName "
.ActiveConnection = dbase
.Open

End With


Set rsconn = Nothing
Set dbase = Nothing
</QUOTE>
Jul 26 '08 #3

debasisdas
Expert 5K+
P: 8,127
TRY USING THIS


Expand|Select|Wrap|Line Numbers
  1. con.begintrans                   'con is the ADODB connection object
  2. con.execute "your insert / update statement here"
  3. con.committrans
  4.  
  5.  
Jul 26 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.