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

Top 5 Contributors of the Month
Sandeep Singh
Post New Web Links

dynamic sql substring problem

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net


i have the following transact sql which is dynamic

but when i add substring function to it to get the first 50 characters of message field i get  error

IF EXISTS (SELECT * FROM sysobjects   WHERE name = 'Messages'   AND type = 'P')

@UserID int,
@mailbox varchar(50)
DECLARE @SQL nvarchar(1000)

select @SQL= 'SELECT substring(message,1,50), I.msgID,I.subject FROM inbox I left outer join users U on U.userid=I.fromUser where '

EXECUTE sp_executesql @SQL

View Complete Post

More Related Resource Links

Problem with Dynamic Button


Hi friends,

I am trying to make a page inspired from http://login.qlikview.com/help.aspx

here I have made a dropdownlist and on clicking I am able to dynamically add the textboxes and radio buttons using placeholders. My problem is I am not able to use a dynamic number of submit buttons. In the page (link above) I need to make the submit button available for two choices and invisible for one.  But the option dynamicbutton is not available alike dynamicTextboxes etc. What could I do? Is there any other way I could figure out to implement this.

Thanking you in advance,


Problem with Dynamic Controls



I have a custom user control that contains within it a repeater control. Inside this repeater I programmatically add another custom user control, which contains a text box and a custom validator. This final custom user control can be added any number of times depending on the application's logic. All of this is part of a wizard step.

When the user completes the step, if any of the data added to the text boxes is incorrect the validator gets fired on post back. However, because I can have any number of these controls added to the repeater, the user has to scroll down to see any of the incorrectly completed boxes.

Due to the controls being added dynamically it is not possible to use a validation summary control - I have tried!!! Therefore, is there away I can use JavaScript to position a cursor or to jump to each incorrectly completed textbox without the user needing to scroll down the page? For example, if there are 10 textboxes, and textboxes 8 and 9 have numbers inside them inside strings, then the JavaScript should jump textbox 9.

Problem with Dynamic Controls inside an UpdatePanel

Hello Everybody ,I have this problem,if anyone could help me i'll be so gratefull. I had been created some dynamic radio buttons in a loop inside a dinamy table which is inside an UpdatePanel , but i can not handle the events my code is below:public void MetodoCreacion(){RadioButton RBtn = null;Table table = new Table();TableRow row = null;TableCell cell = null;for (int i = 0; i < 5; i++){row = new TableRow();cell = new TableCell();RBtn = new RadioButton();RBtn.ID = "RBGN_" + i.ToString();RBtn.GroupName = "RBGN1";RBtn.Text = "Opcion " + i.ToString();RBtn.CheckedChanged += new EventHandler(RBtn_CheckedChanged);RBtn.AutoPostBack = true;cell.Controls.Add(RBtn);row.Controls.Add(cell);table.Controls.Add(row);}UpdatePanel1_UpdatePanelAnimationExtender.Controls .Add(table);}public void RBtn_CheckedChanged (object sender, EventArgs e){Label1.Text = ((RadioButton)sender).ID;}and the controls doesent call the event ...thanks a lot

Dynamic Text Boxes Creation Problem

Hi all, I am creating 5 textboxes in a row. A new creates when user press enter in the last textbox. I have taken a hidden text field and in OnKeyDown of last textbox I am assigning the combination of last textbox Id with the table count  to the hidden field and in VB Code I am checking whether the tableCount + Last textbox Id is equal to the hidden field or not then only I am generating the new row. here is the code In JavaScript On KeyDown of remarks textfield. function funcNewRow(id,count,e) {    var e = event || evt;    var charCode = e.which || e.keyCode;    if(charCode == 13){      e = cancelKey(e);      htxtBox.value = id + count;    } }   In VB Page_load method calling getTableRow() method   if htxtBox.value = "remarks" & (Tbl.Rows.Count + ViewState("TotalClearedItems")) Then  Tbl.Rows.Add(GetTableRow(Tbl.Rows.Count + 1 + ViewState(Panel1.Controls.Add(Tbl))  Panel1.Controls.add(Tbl) htxtBox.Value = "" end if   Here I have to implement a clear functionality such as each row at last contains a check box when user click the check box and press clear button the checked rows have to deleted .   The clear button code as follows : cnt = CInt(Tbl.Rows.Count)  For i = cnt To 1 Step -1 c = Pag

Problem with displaying and processing dynamic data


I need to dynamically generate a list of images in table format.  The images can be found in either art or picts, in temp, or in temp and in one of the other two (duplicate image). 

The idea is to display any duplicates prior to copying anything over from temp to either art or picts, so I'm thinking of adding radio buttons if the same image is found in two folders.  I also want to add a submit button.  The user selects the image they want and clicks the button.  If they want the new file it's copied over then deleted.  If they want to keep the existing file the new one is just deleted.  If they select nothing, both versions of the file are deleted.  So the table will look something like this:

temp         art            picts         process
z-123                                           delete button
() z-234                       () z-234  

Dynamic routing problem when invoking site from remote host.



I have problem described under following link: mvcrouting

Can someone give me some clues how to deal with that ?


Dynamic LINQ Where problem




I stumbled upon a problem while using Dynamic LINQ which is provided by Scott Guthrie. Basically I need a functionality where the user would be able to search by anything while on a gridview. Now the issue is that when the field to be searched is a string it works without problems, when it is an interger it is giving me a {"Operator '=' incompatible with operand types 'Int32?' and 'String'"}. Now the issue is that I would not be able to know what datatype the field is. If I convert the data to an INT it works without problems, but as I said I cannot since I would not be able to know beforehand the database data type. The place where it is giving me the error is shown in bold.


The second issue is that I have a CONTAINS functionality where the user would be able to type in anything and the system will create a CONTAINS linq statement to search for data. For one field it works without problems, while for another field the CONTAINS does not work and it gives me an OBJECT NOT SET TO AN INSTANCE when I try to access the list.  The code is shown underneath. I am using MVC and jqGrid.

private static string BuildWhereClause(JQGridRequest.SearchOperatorOptions SearchOperator, string FieldName)




Problem in displaying values for foreign keys in Dynamic data asp.net web app


I have the following tables in my database which are as given under:


Table 2: CREATE TABLE [dbo].[PromotionCodes]( [PromotionCode] nchar NOT NULL, [CustomerPromotionDiscountID] [int] NOT NULL, [EmployeePromotionDiscountID] [int] NOT NULL, [IsActive] [bit] NOT NULL, CONSTRAINT [PK_PromotionCodes_1] PRIMARY KEY CLUSTERED ( [PromotionCode] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

There is a foreign key relationship between columns (1) PromotionID of table PromotionDiscountValues and CustomerPromotionDiscountID of table PromotionCodes and (2) PromotionID of table PromotionDiscountValues and EmployeePromotionDiscountID of table PromotionCodes

When i browse the PromotionCodes table in the dynamic data listing, the following columns get displayed:

  1. PromotionCode

  2. IsActive

  3. Prom

ASP.NET Dynamic Data Deployment Problem


Hi, everyone..

I have a problem to do ASP.NET Dynamic Data Deployment.

I can deploy my website successfully to a Web Server. Everything runs well, except the dynamic data pages.

When I click on any table pages, it will be rerouted to {table}/List.aspx.

But I got this error on every table.

Server Error in '/MySite' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /MySite/Doctors/List.aspx

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955 

Can you tell me what is the problem? Thanks.

SSIS 2008: Problem reading dynamic file during execution



I have a SSIS 2008 project that reads a bunch of files from a file (always the same file) from Machine A.
My package is running on Machine B and this is where the information is being imported to, my Reporting DB (sql 2008) is also located in Machine B. 
I have a dynamic log file that stores the execution errors every time the package is executed and its name is made up of the timestamp of when package starts executing. The "DelayValidation" option for this connection is set to "TRUE". When i execute my Package from Visual Studio 2008, it runs without a problem.
The problem is when i deploy my package into SQL Server 2008 and try running it through DTEXEC. I always get the following error:


Error: 2010-11-03 14:57:29.06
   Code: 0xC001401E
   Source: MyImportPackage Connection manager "ImportLog"
   Description: The file name "\\ip-address\d$\Logs\ImportManager\20101103_145726.txt" specified in the connection was not valid.

SubString Problem


Hi all,

In a string I need to find the first blank space that  occurs after a '@' symbol has occured in a string. I'm having a problem finding that space.

At the moment I've hard-coded the number 10 into my code, I need to find the endindex in my example below please

        int startindex = 0;
        int endindex = 0;

        string myString = "@BankSimple We're Hiring: Director of Customer Relations";

        if (myString.IndexOf("@") != -1)
            startindex = myString.IndexOf("@") + 1;
            endindex = myString.IndexOf(" ") + 1; //problem on this line

 url = myString.Substring(startindex, 10); myString = myString.Replace(url, "<a target='_blank' href='http://www.twitter.com/" + url + "'>" + url + "</a>"); Response.Write(myString); }


Dynamic Data Deployment problem



My Dynamic Data website works locally in debug mode. When I deploy it to discountasp.net, I can view lists of items, but when I click 'Update' it just refreshes the page without making changes to the DB. Clicking on any paging functionality also just refreshes the current page.

I read on ScottGu's blog that I should add this in the config, however the "dynamicData" element gives me an error and can't be added.

<system.web.extensions><dynamicData dataContextType="" enableTemplates="true">

My config file does include: 

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

I'm running Windows 7, VS2008, and .NET 3.5 and 4.0 is installed locally.

Thanks - any ideas are appreciated!




Dynamic data and Entity framework problem when using a function in RegisterContext


I am trying to use asp.net dynamic data using entity framewrok. my entity framework (edmx file) is in another dll and I dont want to put connection string in config files.
I use this code to register my objectContext in global.asax:

model.RegisterContext(() => new MyObjectContext("EntityConnectionString"), new ContextConfiguration() { ScaffoldAllTables = true });

the first page (the list of tables) is ok, but when i click any table, i get this error:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

 it seems that for the second request, it checks the web.config to look for entity connection string.


dynamic dropdownlist problem !


hi ,

I have dynamic dropdownlist .. and I need to get values when submit !

so what i can write ?

I tryed : foreach(DropDownList ddl in Page.Form.Controls) .. didnt work !!

I work with C#

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Dynamic Data Templates in GridView ASP.NET 3.5

At a high level, Dynamic Data Templates can be seen as a system to very quickly build up a User Interface linked with the relevant data model, immediately enabling you to perform CRUD operations (Create, Read, Update, Delete) on the database using the specified data source. They provide a powerful method for building up these kinds of applications, and I'm going to focus on an overview of what Dynamic Data Templates actually are, and a few ways of customizing them to suit industry needs.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.
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