Hi All..
I am accessing 2 colums from access database and updating them . -
Option Explicit
-
Dim c As New adodb.Connection
-
Dim cn As New adodb.Connection
-
Dim cm As adodb.Command
-
Dim rsnew2 As New adodb.Recordset
-
-
Private Sub cmd_edit_Click()
-
-
If text1.Text = "" Then
-
MsgBox " enter the company name"
-
text1.SetFocus
-
rsnew2.Fields("text1") = text1.Text
-
End If
-
If text2.Text = "" Then
-
MsgBox " enter the company address"
-
text2.SetFocus
-
rsnew2.Fields("text2") = text2.Text
-
End If
-
rsnew2.Update
-
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
-
There is error in RSNEW2.UPDATE ..
CAN ANYBODY HELP ME TO SOLVE MY PROBLEM ??????????
23 1789
You need to call AddNew or Edit method of recordset before calling Update.
You need to call AddNew or Edit method of recordset before calling Update.
rsnew2.Recordset.AddNew
is it correct???
rsnew2.Recordset.AddNew
is it correct???
-
Option Explicit
-
Dim c As New adodb.Connection
-
Dim cn As New adodb.Connection
-
Dim cm As adodb.Command
-
Dim rsnew2 As New adodb.Recordset
-
Dim rsnew3 As New adodb.Recordset
-
-
-
Private Sub cmd_close_Click()
-
Unload.me
-
End Sub
-
-
Private Sub cmd_edit_Click()
-
rsnew3.Open "select * from company", c, adOpenDynamic, adLockOptimistic
-
If text1.Text = "" Then
-
MsgBox " enter the company name"
-
text1.SetFocus
-
rsnew3.Fields("text1") = text1.Text
-
End If
-
If text2.Text = "" Then
-
MsgBox " enter the company address"
-
text2.SetFocus
-
rsnew3.Fields("text2") = text2.Text
-
End If
-
rsnew3.Update
-
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 "edit is successful", but its not updating in database..
What should i do ????
try using this -
c.BeginTrans
-
c.execute "Your update command here"
-
c.CommitTtans
-
try using this -
c.BeginTrans
-
c.execute "Your update command here"
-
c.CommitTtans
-
Error invalid sql statement...
Error invalid sql statement...
you need to write a valid sql statmnet .
Error invalid sql statement...
You need to specify the table and the fields you want to update.
I think you need learn the basics of sql
Sample - "Update <TableName> Set <FieldName1>='My 1st Record', <FieldName2>='My 2nd Record', <FieldNameN>='My N Record'"
Remember enclosing with ' for string, # for dates, and nothing (as in nothing) if it is a number type. : )
You need to specify the table and the fields you want to update.
I think you need learn the basics of sql
Sample - "Update <TableName> Set <FieldName1>='My 1st Record', <FieldName2>='My 2nd Record', <FieldNameN>='My N Record'"
Remember enclosing with ' for string, # for dates, and nothing (as in nothing) if it is a number type. : )
I am using Microsoft Access Database.......
I am using Microsoft Access Database.......
kindly post the UPDATE query that you are executing
kindly post the UPDATE query that you are executing
- Option Explicit
-
Dim C As New ADODB.Connection
-
Dim cn As New ADODB.Connection
-
Dim cm As ADODB.Command
-
Dim rsnew2 As New ADODB.Recordset
-
Dim rsnew3 As New ADODB.Recordset
-
-
-
Private Sub cmd_close_Click()
-
Unload.me
-
End Sub
-
-
Private Sub cmd_edit_Click()
-
rsnew3.Open "select * from company", C, adOpenDynamic, adLockOptimistic
-
If text1.Text = "" Then
-
MsgBox " enter the company name"
-
text1.SetFocus
-
rsnew3.Fields("text1") = text1.Text
-
End If
-
If text2.Text = "" Then
-
MsgBox " enter the company address"
-
text2.SetFocus
-
rsnew3.Fields("text2") = text2.Text
-
End If
-
rsnew3.Update
-
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
Getting message that database has been updated.. but no changes are made ..
I asked you for your UPDATE query .
Refer to my previous post.
I asked you for your UPDATE query .
Refer to my previous post.
- Option Explicit
-
Dim C As New ADODB.Connection
-
Dim cn As New ADODB.Connection
-
Dim cm As ADODB.Command
-
Dim rsnew2 As New ADODB.Recordset
-
Dim rsnew3 As New ADODB.Recordset
-
-
-
Private Sub cmd_close_Click()
-
Unload.me
-
End Sub
-
-
Private Sub cmd_edit_Click()
-
rsnew3.Open "select * from company", C, adOpenDynamic, adLockOptimistic
-
If text1.Text = "" Then
-
MsgBox " enter the company name"
-
text1.SetFocus
-
rsnew3.Fields("text1") = text1.Text
-
End If
-
If text2.Text = "" Then
-
MsgBox " enter the company address"
-
text2.SetFocus
-
rsnew3.Fields("text2") = text2.Text
-
End If
-
C.BeginTrans
-
C.Execute "rsnew3.Update"
-
C.CommitTtans
-
-
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
Can't you understand what is a UPDATE query.
- Private Sub cmd_edit_Click()
-
If text1.Text = "" Then
-
MsgBox " enter the company name"
-
text1.SetFocus
-
Exit Sub
-
ElseIf text2.Text = "" Then
-
MsgBox " enter the company address"
-
text2.SetFocus
-
Exit Sub
-
Else
-
C.Execute "Update Company Set text1='" & Text1.Text & "', text2='" & Text2.Text & "' Where ID='" & txtID.Text & "'"
-
MsgBox "Update successful ", vbInformation, "successful"
-
End If
Im assuming that your field names are text1 and text2 (I've based it on your codes) and lastly txtID.Text as your Primary Key (ID Field)
Rey Sean
Subscribing .
what???? i couldnt understand...
what???? i couldnt understand...
He just wants to subscribe to this thread so that anytime he can go to this thread.
He just wants to subscribe to this thread so that anytime he can go to this thread.
Ok this site is new to me so i dont know much about it...
Ok this site is new to me so i dont know much about it...
BTW, have you fixed your problem?
BTW, have you fixed your problem?
No there is 1 error. I am working on it.
No there is 1 error. I am working on it.
Hope you got it right ^ ^ .
HELLO Vikas,
Sorry for late,
This is the sample after doing all open the database you will see the changes.
Regards
>> ALI <<
Hope you got it right ^ ^ .
Problem finally solved.. Thanks all for helping.. - addnew = True
-
-
On Error GoTo err1
-
-
If text1.Text = "" Then
-
MsgBox " enter the c name"
-
text1.SetFocus
-
Exit Sub
-
End If
-
-
If text2.Text = "" Then
-
MsgBox " enter the c addr"
-
text2.SetFocus
-
Exit Sub
-
End If
-
-
rsnew3.Open "select * from company", c, adOpenDynamic, adLockOptimistic
-
rsnew3.addnew
-
rsnew3.Fields("comp_name").Value = text1.Text
-
rsnew3.Fields("comp_addr").Value = text2.Text
-
rsnew3.Update
-
rsnew3.Close
-
If addnew = True Then MsgBox " add new successful ", vbInformation, "successful"
-
-
If rsnew3.State = adStateOpen Then rsnew3.Close
-
Set rsnew3 = Nothing
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ColinWard |
last post by:
Hi. I am trying to run the following code when the user clicks a button,
but I am getting a syntax error in the SQL. I have a feeling it has to
do with brackets. Can anyone help?
here is the...
|
by: crypto_solid via AccessMonster.com |
last post by:
I have been using a SQL database with a VB5 frontend for about 5 years.
Works well. Unfortunately I don't have access to the source code.
I was tasked with implementing a "job entry" application...
|
by: Darrel |
last post by:
I'm creating a table that contains multiple records pulled out of the
database. I'm building the table myself and passing it to the page since the
table needs to be fairly customized (ie, a...
|
by: Lars Netzel |
last post by:
A little background:
I use three Datagrids that are in a child parent relation.
I Use Negative Autoincrement on the the DataTables and that's workning nice.
My problem is when I Update these...
|
by: davidgordon |
last post by:
Hi,
If I am updating a list of records for a user on an asp page, is there
a way to hold the page updating, even if they refresh the page, until I
have updated all the records.
i.e. rather...
|
by: Alexey.Murin |
last post by:
The application we are developing uses MS Access 2003 database (with
help of ADO).
We have noticed that during massive records updating the size of the
mdb file increases dramatically (from 3-4 to...
|
by: Mathew Butler |
last post by:
I'm investigating an issue I have when pulling data back from MS access I'm retrieving all rows from a column in a table of 5000 rows - accessing a column of type "memo" ( can be 65353 character...
|
by: amatuer |
last post by:
ADODB.Recordset error '800a0cb3'
Current Recordset does not support updating. This may be a limitation
of the provider, or of the selected locktype.
/devag/newProjSave.asp, line 321
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |