Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2004, 08:11 AM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Default value in SQL - new at this :-)

I am sending values from a web form to a SQL database. Most of the values are coming from radio buttons. If a radio button option is not selected, how do I get the value in the SQL table to default to Zero? I tried setting the value in Enterprise Manager in the table to default to zero, but that did not work. It returns the results with blank spaces in the table, if no radio option is selected.

If anyone could tell me how to get this to default to zero I would greatly appreciate it.

Thanks,
Tee
 
Old October 19th, 2004, 10:43 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tee,

Can you post the code you are using to update the database?

Cheers,

Chris

 
Old October 19th, 2004, 11:21 AM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code is below:


<%@ Language="VBScript" %>
<% Option Explicit %>

<%Response.Buffer=True%>

<html>
<head>
<title>Call Dispisition Tool</title>
</head>
<body>
<div align="center">
<table width=600 border="0">


<%
dim conn, rs, sql

Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "File Name=d:\_dbconn\DropShip_HRD.UDL"
SQL = "SELECT * FROM CallTool"


    rs.LockType = 3
    rs.CursorLocation = 3
    rs.CursorType = 3 'Set Static Cursor

    rs.Open SQL, Conn


rs.AddNew
rs("CallType") = Request("calltype")
rs("Services") = Request("services")
rs("Video") = Request("video")
rs("Phone") = Request("phone")
rs("Sales") = Request("sales")
rs("Billing") = Request("billing")
rs("General") = Request("general")
rs("Actions") = Request("actions")
rs("Comments") = Request("comments")
rs("Resolved") = Request("resolved")
rs("CSAP") = Request("CSAP")



rs.MoveFirst
 DO WHILE NOT rs.EOF
%>


<%
rs.MoveNext
Loop


%>

<%
    rs.Close
    Conn.Close
    %>

<tr>
<td>
<p align="center">Thanks for your response.

</tr>

</table>
</div>
</body>
</html>
 
Old October 19th, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tee,

I guess one or more of the fields in your code is the one you are having trouble with, as you are explicitly setting the field in the db to the Request value, the code is setting the db field to blank, this will override the default value set in the db.

You need to validate the Request value, as you have set a default value already, you could just do:
Code:
If Trim(Request("calltype")) <> "" Then
    rs("CallType") = Request("calltype")
End If
You may however want to check that the all field values are valid, as it is very easy for someone to create a form & target your page with it to add bogus data to your db.

Kind regards,

Chris



 
Old October 19th, 2004, 01:05 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
sql server by default?? j_nord ASP.NET 2.0 Basics 0 March 1st, 2007 12:36 PM
What does this("Default Name") mean? webworldman C# 0 July 28th, 2006 07:55 AM
change default aspnetdb to SQL server 2000 alexdcosta ASP.NET 2.0 Basics 3 July 14th, 2006 07:50 AM
default ambrosejp SharePoint Admin 2 April 20th, 2006 01:56 PM
how to set up system time as default for SQL 2000 rainman12 SQL Server 2000 0 October 28th, 2005 10:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.