473,385 Members | 1,983 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,385 software developers and data experts.

Using adodb command - output parameter problem- HELP!

We use a number of similar databases and frequently create a new
database using a backup restore of another similar database. We try to
keep changes between databases in _Additional tables - like Account
Additional, Sale_Additional so most tables stay the same. The latest
restored database (I'll call it DBaseA) is behaving differently in VB6
code and I need help trying to make it work.

I have been using use an ADODB.Command to execute a stored procedure
using adCmdStoredProc and Parameters.Refresh to get an output parameter
value which is an integer. Here is a sample of the VB:

Public Function UnlockAccount(Account_ID As String) As Boolean
Dim LCmd As ADODB.Command
On Error GoTo ERROR_UnlockAccount
UnlockAccount = True
If Account_ID <> "" Then
If DBConnect() Then
Set LCmd = New ADODB.Command
LCmd.ActiveConnection = CN(0)
LCmd.CommandTimeout = 0
LCmd.CommandType = adCmdStoredProc
LCmd.CommandText = "Unlock_Account"
LCmd.Parameters.Refresh
LCmd.Parameters("@Account_ID").VALUE = Account_ID

LCmd.Execute , , adExecuteNoRecords

If LCmd.Parameters("@Status") <> 0 Then
UnlockAccount = False
End If
Else
msgbox "UnlockAccount: DBConnect Failed", "UnlockAccount"
End If
End If
Exit Function
ERROR_UnlockAccount:
UnlockAccount = False
msgbox "UnlockAccount: App Error: " & Err & " " & _
Err.Description, "UnlockAccount"
DBConnect True
Exit Function
Resume 'for debugging
End Function

and this is one of the sps that fails - can't be more simple!
Create PROCEDURE Unlock_Account
( @Account_ID UNIQUEIDENTIFIER,
@Status INTEGER =null OUTPUT) AS
/* Strip functionality */
SET @Status = 0
go

This code is still working in at least 4 other databases. It fails in
database DBaseA with the error:
Invalid character for cast conversion
We are talking about the exact same table definition and the exact same
stored procedure just in different databases.

I fumbled around on the Internet and found a mention in a PowerBuilder
web site of additional parameters in the connect string which seems to
fix the problem in SOME of the stored procs - but not all.
The added parameters are:
DelimitIdentifier='No';MsgTerse='Yes';
CallEscape='No';FormatArgsAsExp='N'
They are not documented in MS but are in Sybase?? No idea why, but some
of the stored proc functions work when I add this to the connect string.

The complete connect string is:
Provider=SQLOLEDB.1;Integrated Security=SSPI;
Persist Security Info=False;
Initial Catalog=DBaseA;
Data Source=PHASE2-S500,1433;
Network Library=DBMSSOCN;
DelimitIdentifier='No';MsgTerse='Yes';
CallEscape='No';FormatArgsAsExp='N'

The databases are on different servers - but they are running the same
version of SQL2000, the same version of Windows. I see no differences
in options set in the different servers or between databases that work
and this one. And dbcc checkdb runs clean.

The compiled code that fails, fails across the board - not just on my
(developer) PC. The same source code works on the same tables in other
databases, including the one we copied....

The final kicker - if I build a SQL statement string and get the
recordset instead, it works like a charm. But I have to fix about 20 VB
functions and check that I do have a recordset and SET NOCOUNT ON in all
20 sps.

I feel this is either something so obvious I will kick myself or so
serious Microsoft will be digging into it.

Any ideas anyone??

Sandie

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 11557
[posted and mailed, please reply in news]

Sandie Towers (st*****@phase2solutions.com) writes:
I have been using use an ADODB.Command to execute a stored procedure
using adCmdStoredProc and Parameters.Refresh to get an output parameter
value which is an integer. Here is a sample of the VB:
...
and this is one of the sps that fails - can't be more simple!
Create PROCEDURE Unlock_Account
( @Account_ID UNIQUEIDENTIFIER,
@Status INTEGER =null OUTPUT) AS
/* Strip functionality */
SET @Status = 0
go

This code is still working in at least 4 other databases. It fails in
database DBaseA with the error:
Invalid character for cast conversion
We are talking about the exact same table definition and the exact same
stored procedure just in different databases.
The first thing to check is of course that you have the right procedure.

Next is to try to narrow down exactly which value that might be causing
the problem. Since you sett @Status to anything, it seems that
@Account_ID is the likely culprit. Using the VB debugger, check how
the .Parameters array looks like. If there is bad version of the stored
procedure that SQLOLEDB uses to get the parameters, this could be an
explanation.
The added parameters are:
DelimitIdentifier='No';MsgTerse='Yes';
CallEscape='No';FormatArgsAsExp='N'
They are not documented in MS but are in Sybase??
When I tried these in a test app that I have, SQLOLEDB barfed at the
format. When I removed the single quotes, and tried them one by one,
I kept getting "Invaliid connection attribute", so I suspect the reason
that MS has not documented these, is because they have no meaning with
the OLE DB provider for SQL Server.
The complete connect string is:
Provider=SQLOLEDB.1;Integrated Security=SSPI;
Persist Security Info=False;
Initial Catalog=DBaseA;
Data Source=PHASE2-S500,1433;
Network Library=DBMSSOCN;
DelimitIdentifier='No';MsgTerse='Yes';
CallEscape='No';FormatArgsAsExp='N'


I would suggest that you beside the incorrect parameters also drop
Network Library. The default network library is called DBNETLIB, I
believe. DBMSSOCN is an old and obsolete one.


--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer...
5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
3
by: MasterChief | last post by:
I have a form that uses the POST method to call up test.asp and it passes what is typed into the text box. Since is uses the Like command the user can enter stuff like %Constant% to get something...
8
by: Ben | last post by:
Hi! I already sent this to the ACCESS newsgroup. But since I do not know really which side is really causing the problem, I have decided to send this inquiry to this newsgroup also, if I may....
1
by: mikegolden | last post by:
An application I'm working on makes extensive use of output parameters and return values, thus forcing me to use the ADODB Command object to execute the stored procs. For recordset returning stored...
3
by: PeeS290 | last post by:
Hi all, Where can I find guidelines about programming SQL based applications in VC++ ? Since MS SQL Server 2008 is strongly promoted, I cannot understand why there is no help for developers....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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 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.