Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 INSERT INTO and SELECT statement

Author  Topic 

ITSSQL
Starting Member

8 Posts

Posted - 2006-07-12 : 06:28:11
Hi

I am developing a UserControl, I save this user control code to the database, which will be loaded dynamically to the Page.

In my user control code consist of following lines:

<asp:SqlDataSource ID="GetDataFromDatabase" runat="server" ConnectionString="<%$ ConnectionStrings:sConnectionString %>"
SelectCommand="SELECT field_defaultvalue FROM cp_productfields WHERE field_product_id='ProductID' AND field_type='DropDownList' AND field_Control_ID='ddVCAuflag'"
ProviderName="<%$ ConnectionStrings:sConnectionString.ProviderName %>"></asp:SqlDataSource>

At this moment, I am manually puting this data to data
base using "INSERT INTO" statement.
But I get following error:

Incorrect syntax near 'ProductID'.

This is because single quotation mark around ProductID (field_product_id='ProductID').
If I change this single quotation to double quotation (e.g. field_id="ProductID") then this works okay.
But in that scenario, SELECT statement fails while execution.

Can anyone please let me know how can I achieve both successfully?

Thanks in advance.


ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-07-12 : 09:06:40
Make the select statement a stored proc and then use EXEC Your_New_Stored_Proc.

Otherwise it might work by changing the single quotes to 3 X single quotes ie Change "'" to "'''" - I'm not sure about this though - you might have to give it a try.



Duane.
Go to Top of Page
   

- Advertisement -