Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 8th, 2004, 01:56 AM
alligator alligator is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 alligator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Storing null and binary value in SQL Dbase using ASP

I am unable to store null values and numbers into my sql database variable that is storing null is trying to store null into field and in case of number i am soring number into numeric field.What is the problem plz help. This is the code of my asp page
<%
Dim objConn
Dim objRs
Dim vbRecCount
Dim strsql,yr,mnth
Dim vbTitle,vbAddVal,vbOffAdd,vbOffPh,vbHoAdd,vbHoPh,v bComm
Dim vbBillAdd,vbPhNo

set objConn =Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DSN=myfile"

'Opening Connection
objConn.open "","ashvini","ash"

if(len(month(date))<2) then
mnth="0" & month(date)
end if
yr=year(date)& mnth & datepart("d",date)
strsql = "select * from mysales WHERE trans_id like '" & yr & "%'"

set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open strsql,objConn,adOpenStatic,adLockOptimistic

'Counting Records for Matching Expression
if objRs.RecordCount=-1 then
vbRecCount=objRs.RecordCount + 2
else
vbRecCount=objRs.RecordCount + 1
end if

'Response.Write objRs.RecordCount
'Response.Write "<br>" & yr & vbRecCount

'Closing Table Connection After Counting
objRs.Close
set objRs=nothing

'Checking if Title is Empty
if Request("title")="" then
vbTitle="Null"
else
vbTitle=Request("title")
end if

'Checking which delivery option was selected(Home/Office)
if (Request("prdDel")=1) then
vbAddVal=0 'Storin Home Address and Phone Number
vbHoAdd=Request("hAdd")
vbBillAdd=Request("hAdd")
vbHoPh=Request("phnH")
vbPhNo=Request("phnH")
'Checking if Address(Office) is Empty
if Request("offAdd")="" then
vbOffAdd="Null"
else
vbOffAdd=Request("offAdd")
end if
'Checking if Ph. No.(Office) is Empty
if Request("phOff")="" then
vbOffPh="Null"
else
vbOffPh=Request("phOff")
end if
else
vbAddVal=1'Storing Office Address and Phone Number
vbOffAdd=Request("offAdd")
vbBillAdd=vbOffAdd
vbOffPh=Request("phOff")
vbPhNo=Request("phOff")
'Checking if Address(Home) is Empty
if Request("hAdd")="" then
vbHoAdd="Null"
else
vbHoAdd=Request("hAdd")
end if
'Checking if Ph. No.(Home) is Empty
if Request("phnH")="" then
vbHoPh="Null"
else
vbHoPh=Request("phnH")
end if
end if

'Checking if Comments is Empty
if Request("CmSgs")="" then
vbComm="Null"
else
vbComm=Request("CmSgs")
end if

'strsql="select * from mysales"
response.write vbAddVal
'Opening Recordset
set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open strsql,objConn,adOpenKeyset,adLockOptimistic

'Storing Records Into Database
objRs.AddNew
objRs("trans_id")=yr & vbRecCount
objRs("title")=Request("title")
objRs("fname")=Request("fname")
objRs("sname")=Request("sname")
objRs("addval")=vbAddVal "binary data"
objRs("hadd")=vbHoAdd
objRs("hph")=vbHoPh "numeric data"
objRs("oadd")=vbOffAdd
objRs("oph")=vbOffPh
objRs("prd_id")=Request("product")
objRs("price")="$" & Request("sprice")
objRs("prd_qty")=Request("qty")
objRs("tdate")=year(date) & "/" & mnth & "/" & datepart("d",date)
objRs("cm_sg")=vbComm
objRs.Update
%>

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Storing null and binary value in SQL Dbase using ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek