Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 January 5th, 2006, 10:10 AM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With INSERT Statement

I am using DetailsView with AccessDataSource control to insert record based on user's input. VWD generates INSERT command like this
Insert Into [table] (fld1, fld2, fld3) VALUES (?, ?, ?)
Everything works fine except in the case where one of the values is not user input but a constant provided by the program. Say, it is stored in variable varXYZ. When I change command to say
Insert Into [table] (fld1, fld2, fld3) VALUES (varXYZ, ?, ?)
I am getting an error.
I would really appreciate help with this...

 
Old January 6th, 2006, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

What is the error? Are you sure that the constant is a valid value? If it is a string are you wrapping it in singles quotes?

J
 
Old January 6th, 2006, 08:10 PM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my case fld1 is Int32. So I tried both
Insert Into [table] (fld1, fld2, fld3) VALUES (130, ?, ?)
and
Insert Into [table] (fld1, fld2, fld3) VALUES ('130', ?, ?)
In both cases I get an error like 'Input string is not in the correct format'.
In reality I do not even know that the value I need to insert is 130, all I know is that it is stored in Session("account_id"). How do I modify Insert command, or can I?

Thanks


 
Old May 19th, 2006, 12:14 PM
Registered User
 
Join Date: Apr 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is kinda similar to what I was wondering. I have a Form View that has a couple of text boxes and that allow me to add my web site news. the thing I want to do is set the current dat to a variable and save that in the database as well as the data that I entered in the text boxes. The original post is a few months old so it doesn't look like there was ever an answer given ..

I know in classic asp you made your inserts like such

set rsSaveData = conn.execute("Insert into table set Field1 = '"&Request("FormField1")&"', Field2 = '"&Request("FormField2")&"', DateField = '"&ValueFromVariable&"'")

basiacally I want to acomplish the same thing in .Net

Thanks

anyone have any ideas??

Dean Forant

Programmer
Delta Mechanical Seals
44 Probber Lane
Fall River, MA. 02720
(508)324-4032 Ext 118





Similar Threads
Thread Thread Starter Forum Replies Last Post
Autonumber and insert into statement. rupen Access VBA 1 July 27th, 2007 02:23 PM
Insert Statement Iashia06 Access 0 April 7th, 2006 12:45 PM
Problems with my Insert Statement brendan82 Access 1 January 6th, 2004 08:30 AM
Problems with my Insert Statement brendan82 Beginning VB 6 1 January 6th, 2004 08:14 AM





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