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

help in editing information in database

P: 9
i need help . im using ADODC for my database settings, VB6. can anyone tell me how to edit the database ? need help asap.. thnx allot
May 2 '07 #1
Share this Question
Share on Google+
5 Replies


Expert 5K+
P: 8,434
i need help . im using ADODC for my database settings, VB6. can anyone tell me how to edit the database ? need help asap.. thnx allot
I think you need to describe in more detail what you want to do.
May 2 '07 #2

P: 9
i have an edit box beside each attribute, for example, i have and edit btn box, beside my name text box (thats for now).. when i click the edit btn box, it will edit the Name information in my database for the selected information in the database...

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3.  
  4. Private Sub cmdAddEntry_Click()
  5.     With Adodc1.Recordset
  6.         .AddNew
  7.         !Name = txtName
  8.         !IC = txtIC
  9.         !Unit = txtUnit
  10.         !Gender = txtGender
  11.         !Address = txtAddress
  12.         !Contact = txtContact
  13.         !Payment = txtPayment
  14.         .Update
  15.         .Requery
  16.     End With
  17.  
  18.  
  19.     Adodc1.Refresh
  20.     Set MSHFlexGrid1.DataSource = Adodc1
  21.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  22.     txtName = ""
  23.     txtIC = ""
  24.     txtUnit = ""
  25.     txtGender = ""
  26.     txtAddress = ""
  27.     txtContact = ""
  28.     txtPayment = ""
  29.     txtName.SetFocus
  30. End Sub
  31.  
  32.  
  33.  
  34. Private Sub cmdEditName_Click()
  35.     With Adodc1.Recordset
  36.     .Update
  37.      i dunno what should i do here...
  38.  
  39.  
  40.  
  41.     Adodc1.Refresh
  42.     Set MSHFlexGrid1.DataSource = Adodc1
  43.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  44.     txtName.SetFocus
  45. End Sub
  46.  
  47. Private Sub cmdRemoveEntry_Click()
  48.  
  49.     With Adodc1.Recordset
  50.         .Move (MSHFlexGrid1.Row - 1)
  51.         .Delete
  52.         .Requery
  53.     End With
  54.     Adodc1.Refresh
  55.     Set MSHFlexGrid1.DataSource = Adodc1
  56.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  57.     txtName.SetFocus
  58. End Sub
  59. Private Sub Form_Load()
  60.     With Adodc1
  61.         .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
  62.             App.Path & "\database3.mdb;Persist Security Info=False"
  63.         .RecordSource = "select * from Tenant order by Name"
  64.     End With
  65.     Set MSHFlexGrid1.DataSource = Adodc1
  66.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  67. End Sub
  68.  
  69.  
  70. Private Sub txtName_Change()
  71.  
  72.  
  73.     If txtName.Text <> "" And txtIC.Text <> "" And txtUnit.Text <> "" And txtGender.Text <> "" And txtAddress.Text <> "" And txtContact.Text <> "" And txtPayment.Text <> "" Then
  74.         cmdAddEntry.Enabled = True
  75.     Else
  76.         cmdAddEntry.Enabled = False
  77.     End If
  78.  
  79. End Sub
  80.  
  81. Private Sub txtIC_Change()
  82.     Call txtName_Change
  83. End Sub
  84.  
  85. Private Sub txtUnit_Change()
  86.     Call txtName_Change
  87. End Sub
  88. Private Sub txtGender_Change()
  89.     Call txtName_Change
  90. End Sub
  91. Private Sub txtAddress_Change()
  92.     Call txtName_Change
  93. End Sub
  94. Private Sub txtContact_Change()
  95.     Call txtName_Change
  96. End Sub
  97. Private Sub txtPayment_Change()
  98.     Call txtName_Change
  99. End Sub
  100.  
  101. Private Sub txtTrackCount_KeyPress(KeyAscii As Integer)
  102.  
  103.  
  104.     Dim TrackKey As String
  105.     TrackKey = Chr(KeyAscii)
  106.  
  107.     If (Not IsNumeric(TrackKey) And Not (KeyAscii = vbKeyBack)) Then
  108.         KeyAscii = 0
  109.     End If
  110.  
  111. End Sub
  112. [XOption Explicit
  113.  
  114.  
  115. Private Sub cmdAddEntry_Click()
  116.     With Adodc1.Recordset
  117.         .AddNew
  118.         !Name = txtName
  119.         !IC = txtIC
  120.         !Unit = txtUnit
  121.         !Gender = txtGender
  122.         !Address = txtAddress
  123.         !Contact = txtContact
  124.         !Payment = txtPayment
  125.         .Update
  126.         .Requery
  127.     End With
  128.  
  129.  
  130.     Adodc1.Refresh
  131.     Set MSHFlexGrid1.DataSource = Adodc1
  132.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  133.     txtName = ""
  134.     txtIC = ""
  135.     txtUnit = ""
  136.     txtGender = ""
  137.     txtAddress = ""
  138.     txtContact = ""
  139.     txtPayment = ""
  140.     txtName.SetFocus
  141. End Sub
  142.  
  143.  
  144.  
  145. Private Sub cmdEditName_Click()
  146.     With Adodc1.Recordset
  147.     .Update
  148.  
  149.  
  150.  
  151.  
  152.     Adodc1.Refresh
  153.     Set MSHFlexGrid1.DataSource = Adodc1
  154.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  155.     txtName.SetFocus
  156. End Sub
  157.  
  158. Private Sub cmdRemoveEntry_Click()
  159.  
  160.     With Adodc1.Recordset
  161.         .Move (MSHFlexGrid1.Row - 1)
  162.         .Delete
  163.         .Requery
  164.     End With
  165.     Adodc1.Refresh
  166.     Set MSHFlexGrid1.DataSource = Adodc1
  167.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  168.     txtName.SetFocus
  169. End Sub
  170. Private Sub Form_Load()
  171.     With Adodc1
  172.         .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
  173.             App.Path & "\database3.mdb;Persist Security Info=False"
  174.         .RecordSource = "select * from Tenant order by Name"
  175.     End With
  176.     Set MSHFlexGrid1.DataSource = Adodc1
  177.     MSHFlexGrid1.FormatString = "    |  Name               | IC              | Unit          |  Gender             | Address              | Contact         | Payment         "
  178. End Sub
  179.  
  180.  
  181. Private Sub txtName_Change()
  182.  
  183.  
  184.     If txtName.Text <> "" And txtIC.Text <> "" And txtUnit.Text <> "" And txtGender.Text <> "" And txtAddress.Text <> "" And txtContact.Text <> "" And txtPayment.Text <> "" Then
  185.         cmdAddEntry.Enabled = True
  186.     Else
  187.         cmdAddEntry.Enabled = False
  188.     End If
  189.  
  190. End Sub
  191.  
  192. Private Sub txtIC_Change()
  193.     Call txtName_Change
  194. End Sub
  195.  
  196. Private Sub txtUnit_Change()
  197.     Call txtName_Change
  198. End Sub
  199. Private Sub txtGender_Change()
  200.     Call txtName_Change
  201. End Sub
  202. Private Sub txtAddress_Change()
  203.     Call txtName_Change
  204. End Sub
  205. Private Sub txtContact_Change()
  206.     Call txtName_Change
  207. End Sub
  208. Private Sub txtPayment_Change()
  209.     Call txtName_Change
  210. End Sub
  211.  
  212. Private Sub txtTrackCount_KeyPress(KeyAscii As Integer)
  213.  
  214.  
  215.     Dim TrackKey As String
  216.     TrackKey = Chr(KeyAscii)
  217.  
  218.     If (Not IsNumeric(TrackKey) And Not (KeyAscii = vbKeyBack)) Then
  219.         KeyAscii = 0
  220.     End If
  221.  
  222. End Sub
May 2 '07 #3

P: 9
anyone can help?
May 2 '07 #4

P: 1
hey buddy i was just lookin around for some for some other vb tips and came across your post...
i think what you want is
with "whatever"
.edit 'here is what you were missing
!bla bla
!bla bla = bla
!and so on
.update
end with
May 19 '07 #5

Expert 5K+
P: 8,434
Thanks for that Er0ck. Sorry dreamonzzz, I completely forgot to get back to this one.

I'm afraid I never did entirely understand the question. Is this what you were looking for?
May 21 '07 #6

Post your reply

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