We help IT Professionals succeed at work.

[ASP] When creating parameter, how do I write datatype, 'bit'?

2,819 Views
Last Modified: 2013-11-25
I am writing an ASP coding with parameter object.
How do I write datatype 'bit' when creating Parameter?

.Parameters.Append .CreateParameter("@newsletter", adBit,adParamInput)

Do I have to create something on my adovbs.inc?

I am lost, help me. Thank you.
Comment
Watch Question

.Parameters.Append .CreateParameter("@newsletter", adInteger, adParamInput)
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
An example for you.
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cnn `cnn is the name of my db connection
cmd.CommandText = "spInsertOrder" `name of my sp
cmd.CommandType = adCmdStoredProc `A const that = 4

`parameters are:
` 1) parameter name
` 2) variable type: 3=integer, 200=varchar, 6=money, 11=bit (boolean)
` 3) parameter type: 1=INPUT, 2=OUTPUT, 3=INPUT/OUTPUT
` 4) parameter length
` 5) value

cmd.Parameters.Append = cmd.CreateParameter("seller_company_id`",3,1,,sellingCompanyID)
cmd.Parameters.Append = cmd.CreateParameter("realm_id",3,1,,session("realmID"))
cmd.Parameters.Append = cmd.CreateParameter("cust_id",3,1,,custID)
cmd.Parameters.Append = cmd.CreateParameter("handling",6,1,,repZero(handling_charge))
cmd.Parameters.Append = cmd.CreateParameter("tax",6,1,,repZero(Request.Form("taxTotal")))
cmd.Parameters.Append = cmd.CreateParameter("pending_code",11,1,,pendingCode)
cmd.Parameters.Append = cmd.CreateParameter("order_id",200,1,50,newOrderID)
cmd.Parameters.Append = cmd.CreateParameter("errNum",3,3,,null)

cmd.Execute
errNum = cmd("errNum")
set cmd = nothing
Jai STech Arch

Commented:
bit when passing thru ASP is meerly an integer ...1 or 0...so you can use integer as your paramter data type...
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
I have to agree with asvforce, the value 11 (which corresponds to the adBoolean enum) is what should be used for the bit data type.
although, adInteger should also work...

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.