Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP Connectionstring not working

Posted on 2014-03-05
4
165 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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