Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 5th, 2006, 10:10 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
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...

Reply With Quote
  #2 (permalink)  
Old January 6th, 2006, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #3 (permalink)  
Old January 6th, 2006, 08:10 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
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


Reply With Quote
  #4 (permalink)  
Old May 19th, 2006, 12:14 PM
Registered User
 
Join Date: Apr 2006
Location: Pawtucket, RI, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:51 PM.


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