Solved

ASP Connectionstring not working

Posted on 2014-03-05
4
160 Views
Last Modified: 2014-03-06
I have this ASP Connection string for my MasterDetail Gridview but I keep getting an error that states that it's an incorrect syntax near '?'.  I'm using a session where clause to grab masterdetail information from the main gridview. Not sure where I can change or what i'm doing wrong. Thanks

SelectCommand="SELECT OrderDetailID, OrderID, ProductCode, SUBSTRING(ProductName, 5, LEN(ProductName)) AS ProductName, Quantity, ProductPrice, TotalPrice FROM OrderDetails WHERE ([OrderID] = ?)"

Open in new window

0
Comment
Question by:Southern_Gentleman
4 Comments
 
LVL 2

Expert Comment

by:gdarcan
ID: 39907843
Sorry but this is not a connection string. You may refer to connection strings at www.connectionstrings.com
0
 

Author Comment

by:Southern_Gentleman
ID: 39907944
It is the SelectCommand after my Connectionstring.  I'm still coming up with the error either or and my error is still the same.

<asp:SqlDataSource ID="sqlPrintedDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="SELECT OrderDetailID, OrderID, ProductCode, SUBSTRING(ProductName, 5, LEN(ProductName)) AS ProductName, Quantity, ProductPrice, TotalPrice FROM OrderDetails WHERE ([OrderID] = ?)">

Open in new window

0
 
LVL 12

Accepted Solution

by:
jitendra patil earned 500 total points
ID: 39908742
try something like below.
cmd = new SQLCommand("SELECT OrderDetailID, OrderID, ProductCode, SUBSTRING(ProductName, 5, LEN(ProductName)) AS ProductName, Quantity, ProductPrice, TotalPrice FROM OrderDetails WHERE OrderID = @orderID)"", conn);
cmd.Parameters.AddWithValue("@orderID", value); //session value
cmd.Prepare();
cmd.executenonquery();

hope this helps.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now