Question

ADODB.Recordset 3001 Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

Asked by: lnshop

Experts:  I am still attempting to add more than 255 characters to a memo field in Foxpro 6.0.  

I am now getting the message above.  Here is the entire inssert and update query code.
sub AddRecord
set insconn=server.CreateObject("ADODB.Connection")
set insrs=server.CreateObject("ADODB.Recordset")
insconn.Open "DSN=ifis"
InsQry="Insert into change_requestrev1 (track_no, subject, req_date, initiator, eff_date, req_desc, bus_value, progrun, progname, t_details, back_plan, risks, app_date, app_by, recommend, comp_date) values ("
InsQry=InsQry & "" & formatnumber(int(trim(Request.Form("strRecNo"))),0,0,0,0) & ",'"
InsQry=insQry & Replace(trim(Request.Form("subject")), "'", "''") &"',"
InsQry=InsQry & "{^" & cstr(year(cdate(Request.Form("req_date")))) & "-" & cstr(month(cdate(Request.Form("req_date")))) & "-" & cstr(day(cdate(Request.Form "req_date"))))  "},'"
InsQry=insQry & Replace(trim(Request.Form("initiator")), "'", "''") & "',"
InsQry=InsQry & "{^" & cstr(year(cdate(Request.Form("eff_date")))) & "-" & cstr(month(cdate(Request.Form("eff_date")))) & "-" & cstr(day(cdate(Request.Form("eff_date")))) "},'"
if Request.form("eff_date")="" then
InsQry=InsQry & "CTOD('//'),'"
end if

**THIS WILL BREAK UP THE LONG STRING IF MORE THAN 200 CHARACTERS ARE ENTERED**

if len(Request.form("req_desc"))>200 then
Workstring=mid(Request.form("req_desc"), 201, len(Request.form("req_desc")))
req_desc=Replace(Mid(Request.Form("req_desc"), 1, 200), "'", "''")
InsQry=insQry & Replace(Mid(Request.Form("req_desc"), 1, 200), "'", "''") & "','"
else
req_desc=Replace(Request.Form("req_desc"), "'", "''")
InsQry=insQry & Replace(trim(Request.Form("req_desc")), "'", "''") & "','"
end if
InsQry=insQry & Replace(trim(Request.Form("bus_value")), "'", "''") & "',"
      if Request.Form ("progrun")="True" then
            InsQry=InsQry & ".T.,'"
      end if
      if Request.Form ("progrun")="False" then
            InsQry=InsQry & ".F.,'"
      end if
      if Request.Form ("progrun")="" then
            InsQry=InsQry & ".F.,'"
      end if
InsQry=insQry & Replace(trim(Request.Form("progname")), "'", "''") & "','"
InsQry=insQry & Replace(trim(Request.Form("t_details")), "'", "''") & "','"
InsQry=insQry & Replace(trim(Request.Form("back_plan")), "'", "''") & "','"
InsQry=insQry & Replace(trim(Request.Form("risks")), "'", "''") & "',"
InsQry=InsQry & "{^" & cstr(year(cdate(Request.Form("app_date")))) & "-" & cstr(month(cdate(Request.Form("app_date")))) & "-" & cstr(day(cdate(Request.Form("app_date")))) &"},'"
if Request.form("app_date")="" then
InsQry=InsQry & "CTOD('//'),'"
end if
InsQry=insQry & Replace(trim(Request.Form("app_by")), "'", "''")      & "','"
InsQry=insQry & Replace(trim(Request.Form("recommend")), "'", "''") &"',"
InsQry=InsQry & "{^" & cstr(year(cdate(Request.Form("comp_date")))) & "-" & cstr(month(cdate(Request.Form("comp_date")))) & "-" & cstr(day(cdate(Request.Form("comp_date")))) &"})"
if Request.form("comp_date")="" then
InsQry=InsQry & "CTOD('//'))"
end if
Response.Write "<br>"
Insrs.open insconn.Execute(InsQry)

Response.Write insQry
Response.Write "<br>"
Response.Write "This is req_desc " & req_desc & "<br>"
Response.Write "The WorkString is " & WorkString
*** END OF INSERT ***

***UPDATE IF REQ_DESC IS LONGER THAN 200 CHARS ***
if WorkString<>"" then
set connA=server.CreateObject("ADODB.Connection")
set rsA=server.CreateObject("ADODB.Recordset")
connA.Open "DSN=ifis"
if err then
response.Write err.Source
Response.Write err.Number
Response.Write err.Description
End if

sql4="Update change_requestrev1 set req_desc=" & "'" & req_desc + Workstring & "'"
sql4=sql4 & " where change_requestrev1.track_no=" & strTrackNo & ""

I have tried both these methods but still get the same error
'rsA.Open connA.Execute(sql4)
rsA.Open connA.Execute(sql4),,adOpenDynamic, adLockOptimistic

Response.Write sql4
end if
end sub
Any help would be greatly appreciated.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-08-30 at 12:06:13ID21545313
Tags

wrong

,

arguments

Topic

Microsoft Visual Interdev

Participating Experts
2
Points
0
Comments
11

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. memo file missing or invalid in foxpro
    hello, i'm encountering an error "memo file missing or invalid" in foxpro, this happens when i save my reports and screens, i don't even have a memo fields in my databases, please help, thanks, mallow
  2. Memo File Corruption
    Does anyone know what causes memo file corruption and how to cure it?
  3. Exporting FoxPro Memo Fields
    I have a FoxPro application I am converting to an AS400 RPG application. I have all the information converted to DB2 tables - all except for the memo table. FoxPro seems to store the memo field in a table with an FPT extension - and I do not have any information on how to g...
  4. FoxPro 3 FGETS vs. FoxPro 6 FGETS
    I have a FoxPro program that was developed in FoxPro 3. It uses the FGETS function to read a line at a time from a text file and populate a memo field. The program runs fine in FoxPro 3, but will not in FoxPro 6. The line: Theline = FGETS(handle, 30000) gives the follo...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: bigbillydotcomPosted on 2005-09-01 at 11:48:29ID: 14804880

*****SIMPLE ANSWER BELOW - BUT PLEASE READ SO YOU UNDERSTAND WHY*****
All of these constructs are wrong
Insrs.open insconn.Execute(InsQry)
'rsA.Open connA.Execute(sql4)
rsA.Open connA.Execute(sql4),,adOpenDynamic, adLockOptimistic

I think you are confusing the .Open method of the connection obejct and the .Open method of the recordset object

Also - you are trying to open a recordset - and the recordset you are trying to open, you are passing an execution of a connection object which, like the error message says:
ADODB.Recordset 3001 Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

The only time you need to use a recordset object is to hold data that will be returned from the execution of a valid SQL command (which requires a connection object - and a connection object requires a connection string)

Since this code is in a Sub (as opposed to a function) I THINK all you are trying to do here is run a sql INSERT statement  followed by a sql UPDATE statement - AND you are not actually "populating" a recordset, like you would if you were getting data, for instance, to display in a grid

ALSO - I don't see any object cleanup in you code above - THIS IS ABSOLUTELY CRITICAL
SINCE ASP PROGRAMMING IS BASICALLY "STATELESS" - THER EIS NO AUTOMATIC OBJECTION TRASH COLLECTION - LEAVING THESE OBJECTS HANGING AROUND WILL CAUSE SEVERE PROBLEMS

********SO***********
here is the bigbillydotcom breakdown of how this all works ( I am using your examples from above, so I am just assuming your connection string is working):

***************************************************
Scenario 1 - Executing a SQL statement that doesnt return a recordset
***************************************************
'create a connection object
set insconn=server.CreateObject("ADODB.Connection")
'open the connection using a valid connection string
insconn.Open "DSN=ifis"
'create a valid sql statement - this sql statement once created should be able to be run in a query window without error
'I am going to keep it simple for now
'this statement will be created using input from an asp form
mysql = "INSERT INTO [Customers] (FirstName,LastName) VALUES ("
'now add form data  - remember to wrap string values in single quote marks
mysql = mysql +" ' "+request.form("FirstName")+" ' ,"
mysql = mysql +" ' "+request.form("LastName")+" '  )"
'the result of the lines above need to be a valid sql statement like the next line
'INSERT INTO [Customers] (FirstName,LastName) VALUES ('Billy','Saxon')
'then - since we are not RETURNING any data by running that sql statement, we need only execute it
'using the connection object we just opened
insconn.Execute(mysql)
'now we need to close the connection object
insconn.Close
'now we need to destroy the object and release the memory for other processes
set insconn = Nothing

So - Scenario 1 works for any sql statement that DOESNT return any data

***************************************************
Scenario 2 - Executing a SQL statement that DOES return DATA, and using that data in a recordset
***************************************************
'create a connection object
set insconn=server.CreateObject("ADODB.Connection")
'open the connection using a valid connection string
insconn.Open "DSN=ifis"
'create a valid sql statement - this sql statement once created should be able to be run in a query window without error
'I am going to keep it simple for now
'this statement will be add data into a recordset and show data in the browser
mysql = "Select * Customers"
'then - since we ARE RETURNING data, we need to create an object to hold that data
'then use the connection object to go and fetch the data and put it in that object
set rsA=server.CreateObject("ADODB.Recordset")
'using the connection object we opened above - we execute the sql statement and assign the value of that execution
'to the recrodset object just created
set rsA = insconn.Execute(mysql)
'no we can do recordset stuff
If not (rsA.Bof or rsA.Eof) then
   Do until rsA.eof
       'show data
        Response.Write "First Name:"+rsA("Firstname")+"   Last Name:"+rsA("Lastname")+"<br>"
  rsA.MoveNext
   loop
End if

'now we need to close that recordset object
rsA.Close
'now we need to destroy that object
Set rsA = Nothing
'now we need to close the connection object
insconn.Close
'now we need to destroy the object and release the memory for other processes
set insconn = Nothing

I hope that helps you to understand the inner working of the connection and recordset objects

Good Luck





 

by: lnshopPosted on 2005-09-01 at 12:44:18ID: 14805375

BigBillyDotComm

Thank you very much for the information and help.  I have modified the update query as shown below.  The update works absolutely fine if the length of req_desc + WorkString are less than 255 characters.

I am only receving the ADODB Recordset error if the combined string is longer than 255.

The recordset and connection cleanup is done at the end of the form.  The form will be populated with the data entry once the user has clicked Add and updated when update is clicked.  When the form is submitted, the asp variables will be passed to the url, parsed, and then merged with a word data source to produce a form.  Also of concern is the length of the complete url once the form is submitted.  Because I need to see the variables in the url, the get method must be used when the form is submitted.  There is a limit on the length of the url, so depending on the length of the two textarea/memo fields, the form may not merge once data entry is complete

I have also tried using AppendChunk which did not work.  

TEST IF LENGTH IS MORE THAN 255
if len(req_desc)+len(WorkString)>255 then
Response.Write "the length is  more than 255" & "<br>"
end if

if WorkString<>"" then
Response.Write "The WorkString is " & WorkString & "<br>"
sql4="Update change_requestrev1 set req_desc=" & "'" & req_desc + Workstring & "'"
sql4=sql4 & " where track_no=" & strTrackNo & ""
insconn.Execute(sql4)
Response.Write sql4
end if

Again, thank you for your help and comments

 

by: bigbillydotcomPosted on 2005-09-01 at 14:25:55ID: 14806071

well
I am not sure of FoxPro (I havent used it in a LONG time) - but Access has a limit on the field type of text to 255 chars
so that would be my first question - what is the req_desc fiield size limit? You may need to change it to a datatype that can hold the number of chars you need

At this point I dont think that AppendChunk is the issue - im thinking it is either the field size limit or an error creating your sql string

suggestion: build your sql string and test it by commenting out the execute that is now failing - ex:

if WorkString<>"" then
Response.Write "The WorkString is " & WorkString & "<br>"
sql4="Update change_requestrev1 set req_desc=" & "'" & req_desc + Workstring & "'"
sql4=sql4 & " where track_no=" & strTrackNo & ""
'insconn.Execute(sql4)
Response.Write sql4
end if

then look at your sql4 string - you should be able to copy and paste it into a sql window in foxpro to see if it runs without errors

ALSO - Since you are building the sql4 string  - you have to replace single quotes (apostrophes) with something else that is not used in SQL (I use DBLDBL Quotes - then when I read it back out, I reverse the process) that may be submitted from the form - i put spaces between the quotes so you can see them - please take them out

like this:
dim ReqAndWorkStr
ReqAndWorkStr =  Replace(req_desc," ' ", " " " ")
ReqAndWorkStr =  ReqAndWorkStr + Replace(Workstring," ' ", " " " ")
sql4="Update change_requestrev1 set req_desc=" & "'" & ReqAndWorkStr  & "'"
sql4=sql4 & " where track_no=" & strTrackNo & ""
'insconn.Execute(sql4)
Response.Write sql4

I think that is where your problem is - let me know!

 

by: lnshopPosted on 2005-09-30 at 08:05:01ID: 14992962

Sorry for the confusion regarding this question.  As indicated in my previous comments, I have resolved the problem myself.  Thank you very much.

 

by: PAQ_ManPosted on 2005-10-10 at 11:36:18ID: 15054405

PAQed with points refunded (500)

PAQ_Man
Community Support Moderator

 

by: lnshopPosted on 2005-10-17 at 08:42:54ID: 15100475

As indicated above, once again, I resolved this problem myself.  The points should not be awarded to PAQ_Mac, as that answer is not accepted.

 

by: lnshopPosted on 2005-10-17 at 12:33:35ID: 15102345

Thank you very much for your assistance.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...