| | |
error updating access database using vb..
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Solved Threads: 0
Hi All..
I am trying to access records and edit and save the changes .. Here is the code
Private Sub cmd_edit_Click()
Dim addnew As Boolean
rsnew3.Open "select * from company", c, adOpenDynamic, adLockOptimistic
rsnew3.addnew
If text1.Text = "" Then
MsgBox " enter the company name"
text1.SetFocus
rsnew3.Fields("text1").Value = text1.Text
End If
If text2.Text = "" Then
MsgBox " enter the company address"
text2.SetFocus
rsnew3.Fields("text2").Value = text2.Text
End If
rsnew3.Update
rsnew3.Close
MsgBox " add new successful ", vbInformation, "successful"
End Sub
Private Sub Form_Load()
Dim cs As String
c.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\COMION.MDB;Persist Security Info=False")
rsnew2.Open "select * from company", c, adOpenDynamic
Me.text1.Text = rsnew2(2)
Me.text2.Text = rsnew2(3)
End Sub
I am getting message that "add new successful" but records are not actually updated...
What should i do ..? can any1 help me pls???
I am trying to access records and edit and save the changes .. Here is the code
Private Sub cmd_edit_Click()
Dim addnew As Boolean
rsnew3.Open "select * from company", c, adOpenDynamic, adLockOptimistic
rsnew3.addnew
If text1.Text = "" Then
MsgBox " enter the company name"
text1.SetFocus
rsnew3.Fields("text1").Value = text1.Text
End If
If text2.Text = "" Then
MsgBox " enter the company address"
text2.SetFocus
rsnew3.Fields("text2").Value = text2.Text
End If
rsnew3.Update
rsnew3.Close
MsgBox " add new successful ", vbInformation, "successful"
End Sub
Private Sub Form_Load()
Dim cs As String
c.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\COMION.MDB;Persist Security Info=False")
rsnew2.Open "select * from company", c, adOpenDynamic
Me.text1.Text = rsnew2(2)
Me.text2.Text = rsnew2(3)
End Sub
I am getting message that "add new successful" but records are not actually updated...
What should i do ..? can any1 help me pls???
there will be a little bit modification on your code and everything will be ok.
try this :-
get back with your result.
regards
Shouvik
try this :-
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim addnew As Boolean addnew=true on error goto err1 If text1.Text = "" Then MsgBox " enter the company name" text1.SetFocus exit sub end if If text2.Text = "" Then MsgBox " enter the company address" text2.SetFocus exit sub end if rsnew3.Open "select * from company", c, adOpenDynamic, adLockOptimistic rsnew3.addnew rsnew3!text1 = text1.Text rsnew3!text2 = text2.Text rsnew3.Update if addnew=true then MsgBox " add new successful ", vbInformation, "successful" if rsnew3.state=adstateopen then rsnew3.close set rsnew3=nothing exit sub err1: err.clear addnew=false msgbox "error in creating the new record." set rsnew3=nothing exit sub End Sub
get back with your result.
regards
Shouvik
Last edited by choudhuryshouvi; Feb 27th, 2008 at 5:18 am.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
![]() |
Similar Threads
- Hello all... Need help updating mysql with php (PHP)
- can help me in updating data (JSP)
- Updating Combo Box (Visual Basic 4 / 5 / 6)
- Updating an Access database with a secondary form (VB.NET)
- Updating a record in an MS Access database file using DataSets (VB.NET)
- Beginners help to migrate from Access to MS SQL fomr VB (Visual Basic 4 / 5 / 6)
- Error connecting to database (ASP.NET)
- adware.mainsearch - how do you get rid of it? (Viruses, Spyware and other Nasties)
- Another Trojan.Bookmarker.Gen (Viruses, Spyware and other Nasties)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to: Update record
- Next Thread: update number of functions being called
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





