HighDots Forums  

making custom Insert

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss making custom Insert in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dprulhiere
 
Posts: n/a

Default making custom Insert - 11-26-2004 , 12:39 PM






Well not totally custom, I am using the command(stored proceedure). I am
trying to learn how to Insert a Number into my database (MSAccess). I was told
theat If I use cdbl() it should work. Could someone please give me an example
using the following code? commissions should be the numeric value. Right now
I get the Data type Mismatch error. (Would assume this means I am trying to
insert text into a field in my datatbase that requires a number. Here is a
simple version of what I am trying to do...

<% If Request(Submit <> "" Then%>
<%

if(Request("tfName") <> "") then Command1__strName = Request("tfName")

if(Request(tfCommission") <> "") then Command1__strCommissions =
Request(tfCommission")

%>
<%
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_RFSOnline_STRING
Command1.CommandText = "INSERT INTO Test (Name, Commission) VALUES ('" +
Replace(Command1__strName, "'", "''") + "', '" +
Replace(Command1__strCommissions, "'", "''") + "') "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

%>
<%End If%>


Reply With Quote
  #2  
Old   
Julian Roberts
 
Posts: n/a

Default Re: making custom Insert - 11-26-2004 , 12:51 PM






You'll need to remove quotes for numberic fields. eg

insert into mytable (mytext,mynumber) values ('some text',5)

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004



Reply With Quote
  #3  
Old   
dprulhiere
 
Posts: n/a

Default Re: making custom Insert - 11-26-2004 , 01:27 PM



I have no problems when the number is not a variable supplied by the user. As
you said the removal of the quotes works great. But... if I try to use
variables, I and rmove the qoutes around the replace like Command1.CommandText
= 'INSERT INTO Test (Name, Commission) VALUES ('' + Replace(Command1__strName,
''', '''') + '','' + Replace(Command1__strCommissions, ''', '''') + '') ' I
just keep getting errors when the page loads. something like...
-------------------------------^ I need help on the above line of code please.
1. How do I convert a user supplied variable into a number? 2. How do I
Insert this variable(numeric) into my database(ACCESS) - an example would be
very helpful 3. Am I going about this all wrong? should I be doing something
different? If so What? Thank you David


Reply With Quote
  #4  
Old   
Gary White
 
Posts: n/a

Default Re: making custom Insert - 11-26-2004 , 02:36 PM



dprulhiere wrote:

Quote:
= 'INSERT INTO Test (Name, Commission) VALUES ('' + Replace(Command1__strName,
''', '''') + '','' + Replace(Command1__strCommissions, ''', '''') + '') '

Replace the above with:

= 'INSERT INTO Test (Name, Commission) VALUES ('' + Replace(Command1__strName,
''', '''') + '', Command1__strCommissions + ')'


Gary


Reply With Quote
  #5  
Old   
dprulhiere
 
Posts: n/a

Default Re: making custom Insert - 11-26-2004 , 02:37 PM



Got it fixed. The line to change was if(Request(tfCommission') <> '') then
Command1__strCommissions = Request(tfCommission') should have been
if(Request(tfCommission') <> '') then Command1__strCommissions =
cdbl(Request(tfCommission'))) Then the no quotes works with out error. ' +
Replace(Command1__strCommissions, ''', '''') + ') - took awaty the single
quotes on either end Thank you for all the help. David


Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.