.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Inserting string into sql parameter. Is their a place holder ?

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
My stored procedure accepts a where clause that is passed in as a parameter. (In this case it is named "@filter") @filter as nvarchar(120) Is their a way to insert a parameter into this @filter string? Look at this where clause that is passed in: 'Where Index > 0 AND Status IN (''Closed'',''Review'')' What I need to do is to insert the view name in front of the "Status" string as follows: 'Where Index > 0 AND dbo.TrView.Status IN (''Closed'',''Review'')' So in other words the string "dbo.TrView." needs to be inserted. How can this be done?I know in C# you can use substitute indicators like {0} etc. But how to do this in SQLI don't know. Can someone help me out?

View Complete Post

More Related Resource Links

Failed to convert parameter value from a String to a Guid.


I am trying to get the UserRole from the logged in user and send it to the database table my code is:

SqlParameter FamilyFriendsOther = new SqlParameter("@Role", SqlDbType.UniqueIdentifier);
        string [] roles = System.Web.Security.Roles.GetRolesForUser();
        if (roles.Length > 0)
            FamilyFriendsOther.Value = roles[0];

adding parameter to query string


hi all,

how do i add a new parameter to an existing query string?


now i need to add a new parameter say, showsearch.

Using IN clause(string parameter) in Stored Procedure

Hi guys. I need to use IN clause in a selection query. From all the resources that I found from google, it's all about adding a function to split a integer parameter into a list. But I got a string parameter, for example 'A1,B1,C1' I tried to use the below where single quotes in @CustCode is double up. ___________________________________ Declare @SQL VarChar(1000)   SELECT @SQL = ' SELECT [something]' SELECT @SQL = @SQL + ' FROM [Table]' SELECT @SQL = @SQL + ' WHERE CustomerCode IN ('  + @CustCode + ')'   EXECUTE (@SQL) _____________ Executing the stored procedure in MSSQL works fine, but it didn't when executing from Visual Studio 2005. Please advice.

Failed To Convert Parameter Value From A String To A Int32

 This is my stored procedure: PROCEDURE[dbo].[uspEXPENDITURE_DETAILS] ( @ExpDetailsID int=0 output, @ExpDet_ExpID int, @ExpDet_Municipality_ID nvarchar(50), @ExpDetGeneralFund money, @ExpDetSpecialRevenue money, @ExpDetCapitalProjects money, @ExpDetTotal money, @Exp_Reporting_Year varchar(10), @ExpComments varchar(max), @Contact_ID int ) AS BEGIN  -- SET NOCOUNT ON added to prevent extra result sets from  -- interfering with SELECT statements.  SET NOCOUNT ON; deletefrom [dbo].[TBL_EXPENDITURE_DETAILS] where ExpDet_ExpID=@ExpDet_ExpID and ExpDet_Municipality_ID=@ExpDet_Municipality_ID and Exp_Reporting_Year=@Exp_Reporting_Year If@ExpDetailsID >= 0 Begin INSERT     INTO [dbo].[TBL_EXPENDITURE_DETAILS] ([ExpDet_ExpID] ,[ExpDet_Municipality_ID] ,[ExpDetGeneralFund] ,[ExpDetSpecialRevenue] ,[ExpDetCapitalProjects] ,[ExpDetTotal] ,[Exp_Reporting_Year] ,[ExpComments] ,[ExpDetCreatedBy] ,[ExpDetCreateDate]) VALUES  (@ExpDet_ExpID , @ExpDet_Municipality_ID , @ExpDetGeneralFund, @ExpDetSpecialRevenue , @ExpDetCapitalProjects, @ExpDetTotal, @Exp_Reporting_Year, @ExpComments, @Contact_ID, GetDate () )    SET @ExpDetailsID = SCOPE_IDENTITY()  return @ExpDetailsID end   Public Sub CreateExpenseDetails() Dim item As GridViewRow Dim txtExpGenFund, txtExpD

failed to convert parameter value from a string to a int32

I am not sure where my app is failing but most probably this is where it is failing.. I think lblExpID.Text is the culprit. Here's the relvant part of my code: Dim lblExpID As Label For Each item In LSGrid.Rows lblExpID = item.FindControl("lblID") If txtExpGenFund.Text <> "" Then sqlArray(i) = ExpDetailsID & "," & (lblExpID.Text) & "," & MunID & "," & _ Val(txtExpGenFund.Text) & "," & Val(txtExpDetSpecialRevenue.Text) & "," & _ Val(txtExpDetCapitalProjects.Text) & "," & expTotal & "," & reportingYear & "," & "Test Comments" & "," & UserID End If Can u help me identify why i am getting this error looking at the sp below: PROCEDURE [dbo].[uspEXPENDITURE_DETAILS] ( @ExpDetailsID int=0 output, @ExpDet_ExpID int, @ExpDet_Municipality_ID nvarchar(50), @ExpDetGeneralFund money, @ExpDetSpecialRevenue money, @ExpDetCapitalProjects money, @ExpDetTotal money, @Exp_Reporting_Year varchar(10), @ExpComments varchar(max), @Contact_ID int ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; delete from [dbo].[TBL_EXPENDITURE_DETAILS] where ExpDet_ExpID=@ExpDet_ExpID and ExpDet_Municipality_ID=@ExpDet_Municipality_ID and Ex

Duplicate URLs in Source Parameter of Query String for All SharePoint Lists

After performing a database attach method of upgrading our existing web application from MOSS 2007 to SharePoint Server 2010, all of our lists that migrated now exhibit an interesting but undesirable behavior.  The DispForm.aspx and EditForm.aspx pages that get loaded are given the Source parameter of the query string but instead of the URL being a single entry like: Source=http://sharepointsite.domain.com/Pages/Default.aspx It winds up putting the URL twice like this: Source=http://sharepointsite.domain.com/Pages/Default.aspx,http://sharepointsite.domain.com/Pages/Default.aspx Naturally this makes processing of the form -- either by choosing OK or Cancel buttons -- result in an HTTP 404 error.  The question we're left with is how in the world did the Source parameter get set that way to begin with.   It wasn't that way in 2007. We had thought that perhaps there was something that didn't migrate over correctly for the existing lists, so I tried creating a new list and then added a new item to the list.  So far so good.  Then attempted to Edit Properties or Edit Item or even View Item, etc. -- essentially triggering the load of the EditForm.aspx and DispForm.aspx  -- and we received the 404 again.  At this point we're not sure what's going on or how to fix it.  We've performed the migration three times so far with t

SharePoint Dataview Insert New Mode - Defaulting a Required Column to a Query String Parameter Valu

I've got a SharePoint DataView with an insert button. there is a required lookup column I want to default to the value of Querystring Value during new mode.  Can I do this in the generated code below? I tried replacing @ApplicantId with @QSApplicantID.. and  tried string(@QSApplicantID) too.. no luck gave me an error: The data source control failed to execute the insert command. Could it be that QSApplicantID (which I've used in my DataView Datasource filter with no problem) is not available during the insert? I think I can do what I want in Javascript but was hoping I could instead right in the XSL markup. *my query string parameter**     ParameterBinding Name="QSApplicantID" Location="QueryString(ID)" DefaultValue="2222222"/ **the new form** SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="ApplicantId" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ApplicantId')}" / **the link** a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}">Insert</a Thanks for any help or information!

Can MVC attributes with a string parameter be fed a function returning a string?


Ok so take for instance this attribute:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "La nuova password e la password di conferma non corrispondono.")]

You can see that the third parameter is a string that I would want to localize, hence I would like to delete that message and replace it with a function call, say something along the lines of this:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = GetLocalization("strErrPassMustMatch")]

Do you think it would be possible? If I got *any* chance to do it, then good, I will be setting up a system to do this :-P otherwise, I'll have to find some other way :-)

What can you tell me?

Thank you!


How to add one control two times into a place holder


My code:

RSS rss = new RSS();
            rss.InstanceId = 1;

            rss.InstanceId = 2;

But when I look at the result, just one RSS instance displayed. How can I add without create two instances of RSS control like this:

RSS rss = new RSS();
            rss.InstanceId = 1;

            RSS rss1 = new RSS();
            rss1.InstanceId = 2;

Assign Query String Values to Selectcommand parameter in




I have two pages EventList.aspx and EventDetail.apsx. When user selects any events [basically list item] on EventList.aspx page [all events are rollup in single sote collection] in am redirected to EventDetail.aspx page with QueryString ListID and ListItemId.

On EventDetail.aspx page i am using


"<Webs Scope='SiteCollection'></Webs><Lists><List ID='{ListID}'></Li

place holder controls disapear


Hello All,

I think it has something to to with postbacks, states and so on, but I aint able to figure it out.

I have two radiobuttonlists from which a user can choose. Based on the selected option controls are dynamicly build in the page in a placeholder.

The information in a textbox within the placeholder should be sended by pressing a button.

When I press the button the whole placeholder, or the controls in it, disapear again.

How can i accomplish that they just stay where the we're ?








How to send parameter in query string on ajax call in asp.net mvc


I want to send selected page value on querystring while navigating through paging. URL that is generating on paging are like this

Link/Index?page=2  or Link/Index?page=3

but on my URL it only shows Link/Index and perform Ajax call but if i disable my Javascript and then navigate through paging it gets Postback and have URL like


which is perfect. But i want this type of URL in Ajax call as well how can i do this? Issue is if we navigate through pages when Javascript is enable it shows Link/Index and when user goes to page no 2 then 3 then 4 and press back button it goes to press page instead of page 3 then page 2. For reference if writing the code which generate paging

<%= Ajax.Pager(new AjaxOptions { UpdateTargetId = "divGrid", LoadingElementId = "divLoading" }, ViewData.Model.PageSize, ViewData.Model.PageNumber,
    ViewData.Model.TotalItemCount, new { controller = "LinkManagement", action = "Index" })%>

decimal place problem in convert string to double


Hi guys, i have a strange error creaping into my web app but am unsure as to how to fix it.  When i run this code on my debug workstation it works fine but when i transfer it to my server things seam to go wrong.

dev station (windows 7) + VS2010
regional and language settings all set to uk
server (windows 2008r2)
regional and language settings all set to uk

What seams to be happening is that when converting a string to a double it works correctly on the dev environment but moves the decimal place to the end on the server.

example code(vb)

dim lat as string = "52.983829"
dim long as string = "-0.036500"

dim latint as double = lat
dim longint as double = long

now on the dev server the value of latint is 52.983829 as you might expect but on when published to the server it becomes 52983829.0

the same with longint on the dev staion it is -0.036500 but on the server it becomes -36500.0

i get equally confusing problems if i try to change it to an integer instead.


can anyone help point be in the right direction?

Image background color is showing while i drag in content place holder in master page ???


Hi  ...

I had few icons and images in my old web project which had no issue with the images and icons background color.

Now i have changed the total look and layout of my web site. After doing so , my old images and icons as well as new images and icons backgroud color is also displaying in the image.

The same image is looking good in my old web site layout ...

I tried all the stuff to show only image not image background ... But , it is not happening ....

The main thing is the same images and icons background color is not showing in my old design ...

Look at the image background , it has grey color background. It was not happening in my old web site design

Plz help me to solve this .... 

reposted with no help: passing a string parameter to a web method


I have a web form (html) and I'm trying to pass a single string as a parameter to my web method, (this should be simple but no one can seem to answer me)

<script type="text/javascript" language="javascript">
        var qs = new Querystring();
        var v1 = qs.get("TorVName");
        //var jsonData = JSON.stringify(v1);  
        //var list = v1;
        //var jsonText = JSON.stringify({ list: list });
        $().ready(function() {
                type: "POST",
                url: "Default.aspx/GetColumns?TorVName=" + v1,
                data: {},
                contentType: "application/json; charset=utf-8",

Specifying a comma separated string as a parameter value in BIDS


Hi, I have a problem that is driving me mad.  I am trying to create a report in BIDS that pulls data from oracle database and generates the report of call it sales by month.  What I'm attempting to do is to create a parameter in BIDS and force a comma separated value into it and then pass that value into SQL statement for an oracle dataset in other words.

BIDS:  Parameter @QTR Paramater label QTR1  Paramter value ('01','02','03')

           Parameter @Year Parameter label Year Parameter value 2010

Oracle side: select * from ....

where year=:Year and

month in :QTR

Whenever I try to run it like that the report generates but it's blank.  Replacing value in QTR parameter with a single non quoted value like 01 generates report perfectly fine.  Could anyone shed some light as to how properly specify comma delimited strings to be used in :in: statements. 

help inserting an empty string and a default date thru a stored procedure


I want to insert an empty string in a nvarchar field and a default date like a base date in a datetime field inside a stored procedure without passing it the value thru a parameter

how is this done?

INSERT INTO deals_SoldItems (











this dont work



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend