473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ADODB replacing values in your DB

Hey guys,

I would like to know how to replace values in your database via ADODB.

Example:
(I would want to replace the value LOCATION of ID 1001 which is Oliver to Laguna.)

ID NAME LOCATION
1001 | Oliver | Quezon City
1002 | Paul | Laguna

I've made 2 buttons, 1 is to search the other one is to insert. Is my logic right? Or is there another way?

Here are my codes:

(FOR SEARCHING)
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "DSN=db1"
b = (InputBox("Enter Student Number"))
Set rs = cn.Execute("select * from Student_Info")
While rs.EOF = False And rs.BOF = False
If b = rs.Fields("Student_No") Then
Text3.Text = rs.Fields("Student_No")
MsgBox ("user found")
Exit Sub
Else
rs.MoveNext
End If
Wend
MsgBox ("user not found")


(FOR INSERTING):

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "DSN=db1"
Set rs = cn.Execute("select * from Student_Info")
While rs.EOF = False And rs.BOF = False
If rs.Fields("Student_No") = Text3.Text Then
er = Combo1.Text
et = Text3.Text
-->'Set rs = cn.Execute("Insert into Student_Info (course) values ('" & Combo1.Text & "' ) where rs.fields("Student_No")=text3.text")
-->'Set rs = cn.Execute("Update Student_Info SET course = er Where Student_No = et;")
rs.Fields("course") = er
MsgBox ("pasok")
Exit Sub
Else
rs.MoveNext
End If
Wend

End Sub

Legend:

(-->) Neither one of these codes does what i want them to.


Is there a problem of syntax or logic, me and my group are kinda stuck at this point. Please help.

Thanks in advance.
Oct 6 '07 #1
10 2214
i tried

Private Sub Command5_Click()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "DSN=db1"
b = (InputBox("Enter Student Number"))
Set rs = cn.Execute("select * from Student_Info where Student_No = '" & b & "'")
If (rs.EOF) And (rs.BOF) Then
MsgBox "Record does not exist!", vbCritical
Else
rs.Fields("course") = Combo1.Text
MsgBox ("user found")
Exit Sub
End If
MsgBox ("user not found")
End Sub



But i encounter the error "Current recordset does not support updating. This may be a limitation of the provider, or of the selected lock type."

What should i do?
Oct 6 '07 #2
Ali Rizwan
925 512MB
Hey guys,

I would like to know how to replace values in your database via ADODB.

Thanks in advance.
Here is an atachment for replacing any field.
Check it
GOODLUCK
ALI
Attached Files
File Type: zip REPLACE.zip (10.0 KB, 114 views)
Oct 6 '07 #3
This is great ali but i think this is ADODC.

We are only permitted to use ADODB.
Oct 6 '07 #4
Ali Rizwan
925 512MB
This is great ali but i think this is ADODC.

We are only permitted to use ADODB.
Hello,
I think if you use adodc it will easy for you because it is quick and easy to buid database with it.
If you are a bigginer then it will better than adodb
else
i ll demonstrate another project for you.
GOODLUCK
ALI
Oct 6 '07 #5
Sorry but we are only permitted to use ADODB, yes ADODC is easy but me and my friends must follow what our professor told us. It's a pain, i know.
Oct 6 '07 #6
Ali Rizwan
925 512MB
Sorry but we are only permitted to use ADODB, yes ADODC is easy but me and my friends must follow what our professor told us. It's a pain, i know.
Hello,
What kind of error you are recieving?
Please tell.
GOODLUCK
ALI
Oct 6 '07 #7
"Current recordset does not support updating. This may be a limitation of the provider, or of the selected lock type."
Oct 6 '07 #8
jrtox
89
Hey guys,

I would like to know how to replace values in your database via ADODB.

Example:
(I would want to replace the value LOCATION of ID 1001 which is Oliver to Laguna.)

ID NAME LOCATION
1001 | Oliver | Quezon City
1002 | Paul | Laguna

I've made 2 buttons, 1 is to search the other one is to insert. Is my logic right? Or is there another way?

Here are my codes:

(FOR SEARCHING)
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "DSN=db1"
b = (InputBox("Enter Student Number"))
Set rs = cn.Execute("select * from Student_Info")
While rs.EOF = False And rs.BOF = False
If b = rs.Fields("Student_No") Then
Text3.Text = rs.Fields("Student_No")
MsgBox ("user found")
Exit Sub
Else
rs.MoveNext
End If
Wend
MsgBox ("user not found")


(FOR INSERTING):

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "DSN=db1"
Set rs = cn.Execute("select * from Student_Info")
While rs.EOF = False And rs.BOF = False
If rs.Fields("Student_No") = Text3.Text Then
er = Combo1.Text
et = Text3.Text
-->'Set rs = cn.Execute("Insert into Student_Info (course) values ('" & Combo1.Text & "' ) where rs.fields("Student_No")=text3.text")
-->'Set rs = cn.Execute("Update Student_Info SET course = er Where Student_No = et;")
rs.Fields("course") = er
MsgBox ("pasok")
Exit Sub
Else
rs.MoveNext
End If
Wend

End Sub

Legend:

(-->) Neither one of these codes does what i want them to.


Is there a problem of syntax or logic, me and my group are kinda stuck at this point. Please help.

Thanks in advance.
chuckzter, Muzta Repa!

I Really dont spoonfeed student, but your excepted coz youre a filipino..
By the way im in Sta.maria bulacan now, But i Graduated in STI-College ORMOC, ORMOC city.


Just download the attachment i made.
Its not the same the way you Design your project but it can help you.

Regards
Ervin
Attached Files
File Type: zip sample.zip (23.7 KB, 100 views)
Oct 7 '07 #9
Hey bro, thanks for the sample zip. I'll analyze it and try to apply it to our system.


Off-topic:

STI-Southwoods bro, i'm in my 3rd yr now taking up computer science.
Oct 7 '07 #10
jrtox
89
Hey bro, thanks for the sample zip. I'll analyze it and try to apply it to our system.


Off-topic:

STI-Southwoods bro, i'm in my 3rd yr now taking up computer science.
Hello

OK, Good luck

Regards
Ervin
Oct 7 '07 #11

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

Similar topics

4
by: Adrian | last post by:
Hi, I have an ASP page on an intranet IIS server that posts data via a System DSN to an Access DB, normally it works fine however sometimes it returns 0 for success but no data is added to the...
1
by: dcrespo | last post by:
Hi to all, I have functions defined in an xml-rpc server. Some functions query to a Postgres database (using adodb) and return its recordset. So, if some xml-rpc client runs the mentioned...
0
by: Brendan Reynolds | last post by:
I have a web service that takes the XML representation of a dataset and uses XSLT to transform it to the format required to open a disconnected ADODB recordset on the XML, and returns the...
12
by: anonymous | last post by:
Hello, I need to replace this char  with another char. However I am not able to acieve this. I tried this but it doesnt work: str = str.Replace(chr(asc(194)), "") Can somebody help ?
3
by: Yuk Tang | last post by:
I'm trying to grab the fieldnames and values from a recordset, but I'm getting errors. I have an idea what the error might come from, but I'm not sure how to correct it. I'm connecting to an...
7
by: Aleks Kleyn | last post by:
At this time my code use ODBC and adodb to access database. Working with win vista i discovered that way i cannot work with SQL server. it is not clear this is bug or Microsoft suppose to give...
4
by: T | last post by:
-------------------------------------------------------------------------------- I tried this audit trail code, using 2003 and it works great, I try and use it at work w/97 and it blows up:...
5
by: Jahren | last post by:
Hi! i'm new here. this place looks nice so i would like to try my luck here! I've a question : How can I insert multiline richtext into MSACCESS database? at first I thought I could store it...
2
by: Jerry Winston | last post by:
We all know SQL injection attacks can easily get break SQL command strings concatenated with unsanitized user input fields: set commandObj = Server.CreateObject("ADODB.Connection") set rs =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.