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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

Question with this code

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
 
Hello all I have a question with this code, I'm still learning and I'm not sure what can be the possible error with this code Thanks in advance for the help! The error showed is this ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Index and count must refer to a location within the string. Parameter name: count Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. Parameter name: count Source Error: Line 54: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Line 55: Line 56: Usuario = Context.User.Identity.Name.Remove(0, 6).ToString Line 57: Line 58: Dim myConnection As New Data.SqlClient.SqlConnection ----------------------------------------------------------------------------------------------------------- This is my code ------------------------------------------------------------------------------------------------------------ Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Usuario= Context.User.Identity.Name


View Complete Post


More Related Resource Links

Question about user used to execute code from app_code

  

 Hello. I would like to know something about code execution  in App_Code folder.

Under wich user executed code from app_code.

I'm using impersonate in web.config


Embedded code block question

  
Hello,i know it's a very basic problem but i can't use an asp.net code block the way i want.I have used those before but it seems i encountered a case i haven't seen before.<asp:SqlDataSource ID="SqlDataSourcetblCategoriesPourListe" runat="server" ConnectionString="<%$ ConnectionStrings:BottinConnectionString %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT label from mytable WHERE (HOrder = @HOrder)))"> <SelectParameters> <asp:QueryStringParameter DefaultValue="<% (int)GetDefaultValue()%>" Name="HOrder" QueryStringField="HOrder" /> </SelectParameters> </asp:SqlDataSource>Whenever i run this, i get an exception:Syntax error converting the nvarchar value '<% (int)GetDefaultValue()%>' to a column of data type int.How can i avoid this ?I am not doing it in the code behind because i use nested gridviews and sqldatasources.  Can't access nested sqldatasources from code behind, as far as i know.

SSRS embedded code scope question

  
Can someone please provide some insight about how embedded code works in terms of scope?  I am trying to show moving average values on charts using the custom code from http://msdn.microsoft.com/en-us/library/aa964128%28SQL.90%29.aspx.  My chart has an actual series group, which has multiple values.  To be specific, my data series is profit per unit; my series group is division; and I have time on the X axis.  The "division" series group can have multiple values such as "US", "Europe", and "Asia".  Looking at the moving average custom code from the above link, I really wonder how the global variables, such as "queue" and "queueSum", are handled across the multiple series group values.  Can it correctly separate the queue for division "US" from the queue for division "Europe" and "Asia"?  Also, I have multiple charts ont he same report and they all use the moving average custom code.  Does SSRS use different instances of the global variables so that one chart is calculated separately from another? 

General question: Using the VS Designer vs. the Source Code

  
I just finished Sams Teach Yourself ASP.Net in 24 Hours. I am now going through the Data tutorials here. I am a beginner at ASP.Net. One thing that I am having a little bit of trouble with is the idea that I am using the Designer in Visual Studio for just about everything except for a few code tweaks. I used to do a lot of HTML, JavaScript and CSS. I even did some programming (PowerBuilder). So, I am used to writing/typing code instead of using a Designer. (I always liked writing web pages in a text editor.) When I look at the code generated by the Designer in Visual Studio, I can understand what is going on there. But, to sit down and write that code instead of using the Designer to me seems impossible. There is just so much there. From what I understand, ASP.Net and Visual Studio were created to help streamline the code writing process. I suppose if I was used to writing VB code to create applications I might look at this from a different angle. But, I am learning ASP.Net using the VS Designer. Any comments or suggestions from experienced coders? I really don't want to have a battle between people who use the Designer and the Source Code editor. I am just hoping for some comments that will help newbies. Thanks.

Newbie question about SQl code and SSIS

  

Hi Guys,

Im coming from a SAP Datawarehouse background and i don't know much about sql queries or statements. I was wondering if i need this knowledge to learn SSIS, and if so in what situations?

Thanks in advance


Infopath form timesheet question on rounding time and using code

  

We have a timesheet form that has 4 time fields:  Start Time, End Time, Actual Time and Billable Time. 

Our Start Time, End Time and Actual Time buttons and field calculations work just fine, but we want the 4th field to calculate the billable time by rounding UP to the quarter-hour.

For example:

Start Time - 9:00am

End Time - 11:20am

Actual Time -  2:20

Billable Time - 2:30 (or 2h30min)

 

I'm new to Infopath and not sure how we would accomplish this.  What type of code would I need and can I even use code on that Billable Time field to accomplish this?

 

Thanks for any help you can give me!

 


A few question on optimizing the code

  

1. Does comments in code affect the processing time on server?

2. Do I decrease the process time if I change <asp:Label></asp:Label> to <asp:Label />

3. Is there a difference in writing "using System.Web.Security;" at the beginning of the code or
 specifying it when it is needed "System.Web.Security.FormsAuthentication.SignOut();"

4. Should I spend more time on trying to reuse connections if possible when processing the page.
   Someone said that .NET does this automatically if the use of the connection happens within a certain time?

5. Does formatting and long variable/function names affect the processing of the page and is it worth anything to shorten them?


Thanks in advance!

/zalk


Infopath Question: XPath code to remove domain name from AccountID field in Person/Group Picker

  

I have an infopath email based submission form where I am using the Person/Group picker as a way for people to find people in the active directory to CC the form to. I was using the field "DisplayName" in the control and discovered that when you try to CC several employees, that it would disrupt the rules and you can't send the form.

I want to use the field "AccountID" but it includes the domain before the email alias (for ex. REDMOND\johndoe). Is there a formula code I could use to remove the domain from every email alias. Right now my CC formula is concat(SubmitterAlias, "; ", DisplayName)


Novice question regarding code behind

  

I am new to ASP.Net and am having problems.  I'm trying to create a web app based on a tutorial and I can't get it to work.  The code is from Beginning ASP.NET 3.5 in C# 2008, 2nd Ed (pages 141/142).  Here's what I'm doing (using VS 2010 on WinXP):

File/New Project/Web -> ASP.Net Web Application

Leave the default Name

Delete all code from Default.aspx and replace with: 

<%@ Page Language="C#" AutoEventWireup="true"CodeFile="CurrencyConverter.aspx.cs" Inherits="CurrencyConverter" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Currency Converter</title>
</head>
<body>
     CHAPTER 5 n 140 WEB FORM FUNDAMENTALS
    <form runat="server">
        <div>
            Convert:  
            <input type="text" ID="US" runat="server" />
              U.S. dollars to Euros.
            <br /><br />
            <input type="submit" value="OK" ID="Convert" runat="server"
                OnServerClick="Convert_ServerClick" />
            <br /><br />
            <div style="font-weight: bold" ID="Result" runat=&qu

Newbie question: Are there any code changes required in an app when introducing SQL Replication?

  

Hi,

We are investigating introducing SQL Replication (transactional model) to mitigate the usage of our main database from a remote site (so, we would have a replication at the remote site).

What we want is for users to write only to the Publisher, and read from the local Subscribers.

I have just assumed so far that SQL Replication will be completely transparent and handle the replication internally, so that we won't need to change anything in our client applications connecting to the DB, but I can't actually find any documentation that confirms this (it just seems to be the most obvious way for this to work).

Can you please point me to some documentation that clarifies this, or just confirm the actual behaviour here?

Thank you!

 


Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

  
When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

  
You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

  
Free C# Code Snippets

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Microsoft StyleCop: Source Code Analyzer for C#

  
StyleCop is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while StyleCop analyzes the source code directly. For this reason, FxCop focuses more on the design of the code, while StyleCop focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.

Code spelling checker extension for visual studio 2010

  
Building a spelling checker for source code as an extension for visual studio 2010.
Categories: 
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