|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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 %> |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Storing null and binary value in SQL Dbase using ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|