-
May 15th, 2006, 08:11 AM
#1
Thread Starter
Lively Member
[RESOLVED] error converting data type varchar to bit in MS SQL
hey guys can someone please tell me what im doing wrong.
My sproc is something like this:
Code:
create proc dt_addnewcustomer
@CustIsInactive bit,
@CustFName varchar(100)
SET NOCOUNT ON
AS
insert into tlbcustomers (CustFName, CustIsInactive) VALUES (@CustFname, @CustIsInactive)
go
my vbcode is like this:
VB Code:
dim CustIsInactive as boolean
CustIsInactive = false
Set adocommand = New ADODB.Command
With adocommand
.ActiveConnection = con
.CommandType = adCmdStoredProc
.CommandText = "dt_addnewcustomer"
.Parameters.Append .CreateParameter("@CustFName", adVarChar, adParamInput, 100, Trim(CustFName.Text))
.Parameters.Append .CreateParameter("@CustIsInactive", adboolean, adParamInput, 1, CustIsInactive)
.Execute , , adCmdStoredProc + adExecuteNoRecords
Set adocommand = Nothing
end with
I really dont see what im doing wrong, and it's driving me nuts!! Someone please help
-
May 15th, 2006, 08:21 AM
#2
Re: error converting data type varchar to bit in MS SQL
SET NOCOUNT ON goes in the AS statement...
Code:
create proc dt_addnewcustomer
@CustIsInactive bit,
@CustFName varchar(100)
AS
SET NOCOUNT ON
insert into tlbcustomers (CustFName, CustIsInactive) VALUES (@CustFname, @CustIsInactive)
go
Why are you using a BIT parameter? Is that the datatype of CustIsInactive? adboolean seems like it did not properly case after being typed - is that accurate? I've never used a BIT parameter or datatype myself - try changing the parameter definition to INT and see if that works...
-
May 15th, 2006, 08:27 AM
#3
Thread Starter
Lively Member
Re: error converting data type varchar to bit in MS SQL
Originally Posted by szlamany
SET NOCOUNT ON goes in the AS statement...
My bad, in my sproc it is in the as statement.
I have tried everything, if i change it to int the error changes to error converting data type varchar to int??
It is if the parameter is applying it as varchar even though i have explicity told it to be boolean
-
May 15th, 2006, 10:40 AM
#4
Re: error converting data type varchar to bit in MS SQL
Using the Bit datatype and adBoolean is fine.
The problem is you have reversed the parameters when appending them to the Command object - @CustIsInactive should be appended first.
Or
If you are using ADO 2.7 or higher, set the .NamedParameters property to True.
-
May 16th, 2006, 05:58 AM
#5
Thread Starter
Lively Member
Re: error converting data type varchar to bit in MS SQL
Originally Posted by brucevde
If you are using ADO 2.7 or higher, set the .NamedParameters property to True.
Bruce your a GUN! thanks sooo much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|