Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 August 2nd, 2005, 09:17 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Insert query problem. -- Solved

Hi All,

I am using an insert query, viz.

        objConn.Execute ("insert into empmaster values(" & Request.Form("empid") & ",'"& Request.Form("fname") & "','"& Request.Form("lname") & "',#"& Request.Form("doj") & "#,#"& Request.Form("dob") & "#,'"& Request.Form("mobile") & "','"& Request.Form("phoneno") & "','"& Request.Form("email") & "','1'," & Request.Form("TeamList") & ",'"& Request.Form("designation") & "','password','" & Request.Form("rollno") & "'," & Request.Form("Manger") & ",#" & Request.Form("Ldate") & "#" & ")")

Now problem comes when some values are left blank, i.e. say doj or dob, it give error in that case, what if I want to permit the as blank?

Thanks in advance.:)

Rupen Anjaria.
We CAN'T avoid problems, but of course can solve it.
 
Old August 2nd, 2005, 02:27 PM
Authorized User
 
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check the field in your database to see if it allows zero length

 
Old August 2nd, 2005, 06:06 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

DO as g2000 has said. When you say it gives an error, what error would be helpfull. IMO if you do not need to address a field, dont. Are you aware you can set no nulls and a default value?

Wind is your friend
Matt
 
Old August 2nd, 2005, 11:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try to insert like this.

set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="....."
cn.Open

isql1="insert into emp (empno,name,dept) values ("
isql2="'" & empno & "',"
isql3="'" & name & "',"
isql4="'" & dept & "')"

sql=isql1+isql2+isql3+isql4

cn.Execute sql


it will more easy.
for blank record, ie.

if Isdate(date_Recd) then
    isql3="'" & date_recd & "',"
else
    isql3="NULL,"
end if


Your coding may be some syntax error.

Mateen




 
Old August 3rd, 2005, 07:01 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Hi All,

I have set to allow zero leng in db. or say it is allowing null in db.

Mateen: Your solution is worknig fine.

Thanks..

Rupen Anjaria.
We CAN'T avoid problems, but can solve it.
 
Old May 15th, 2007, 08:59 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

u can create a function which will convert the blank values to zero






Similar Threads
Thread Thread Starter Forum Replies Last Post
SOLVED...VBA and Update Query eusanpe Access VBA 8 June 2nd, 2008 08:48 AM
Problem in insert query ? moreexited Visual Studio 2005 1 July 30th, 2007 08:03 AM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Problem Solved. blackdevil1979 Beginning VB 6 0 March 22nd, 2005 09:55 PM
Database access from java, INSERT query problem nitusincog BOOK: Beginning Java 2 1 July 21st, 2003 10:26 AM





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