Format A String Like 1000 To 10:00 ?
Jul 2, 2010I am using C# , Asp.net2.0
I just need to format a string like 1000 to 10:00
I used string.Format("{0:##:##}", sttime)) but it showing the same 1000
I am using C# , Asp.net2.0
I just need to format a string like 1000 to 10:00
I used string.Format("{0:##:##}", sttime)) but it showing the same 1000
i am making a dynamic query, it contains more than 1000 characters.
when i am trying to execute it then loss the query , it is skipping some charachters.
why it happens and how can i handle it ?
varchar variable's length is 5000 .
i am using sql server inbuilt mail system for sending mail.and i made SP to call dbmail sp
now my problem is when i call sp it get executed fine but in last suppose 1000 mails queued then 1000 times i get mail queued.and that my connection time out .i extend connection time out limit but i get error msg like
"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Mail queued."
my mail get queued well proper but due to 1000 or 100000 mail queued its lost of msg make problem.
I'm bulding document-from-template engine. At certain points I need to match on Reg Exp groups and replace template text with content from a db.
I 'hardcoded' my RegExp initially, doing something like: Regex r = new Regex(@"{DocSectionToggle::(?<ColumnName>w+)::(?<ResponseValue>.+)}[[(?<SectionContent>.+)]]", RegexOptions.Multiline);
it does group capture, so the syntax isn't the prettiest.
Just to make things neater and because I want' to keep the patterns in web.config or elsewhere, I've 'evolved' algorithm to something like:
[code]...
But I'm getting an error: 'Input string was not in correct format'.
Is this a limitation of string.Format(...)?
[code]....
Isn't this how u convert string to int ?
int.Parse(e.CommandArgument.ToString());
Whats wrong ?
i facing a problem to change the date format at gridview display.
below is my coding:
[code]....
I'm concatenating a string in codebehind to use in a sql select statement.
in aspx
<asp:Label ID="LabelHidden" runat="server" Visible="False"></asp:Label>
SelectCommand="SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList_Employees" Name="ID"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="LabelHidden" Name="ActivityName"
Type="String" />
</SelectParameters>
in codebehind
foreach (ListItem li in ListBox_Activities.Items)
{
if (li.Selected)
{
queryBuilder += li + "', ";
}
queryBuilder = queryBuilder.Substring(0, queryBuilder.Length - 1);
LabelHidden.Text = queryBuilder;
When i run the code it comes up blank. I did a query trace and it seems to be running as
exec sp_executesql N'SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)',N'@EmployeeID int,@ActivityName nvarchar(50)',@EmployeeID=4,@ActivityName=N'Production Technical Support'', Tools Development'','
with exta "'s
How can i format the queryBuilder string correctly in my code?
I have project in development where string operations like "Hi " + variable + ", welcome to Project" are used at many places (given example is very minor one).
One of the requirement is to convert it to string.format style.
It is very long and tedious job, where I would not like to break earlier working code due to any human error might happen while converting it.
I would like to if any Macro or VS command which I can create to handle it. Just like we mark block of code and do Extract function in Re-factor options.
I have a displayFormat pattern "$###,###,###;-$###,###,###;#"( it can be different too) and I want to reformat the value in the AspxTextbox after deleting the ',' on GotFocus and LostFocus events by calling the following JavaScript function :
[code]....
I have tried to use ASPxFormatter but it is an internal class that is not indented to be used in a user project.Using String.Format('{0:' + displayFormat + '}', parseInt(value))); didn't work too , it threw an exception since String.format doesn't accept this format of pattern,Can you provide a way to reformat my string to any pattern I want not only the one I recite since ?
I am using Linq to SQL. I have a table with a uniqueidentifyer column.
I need to insert 1000 records, each with all the same values except for the uniqueid field.
I know the syntax to insert a single record for example where dc is a DataContext():
[Code]....
Does anyone know how if there is a way, other than looping 1000 times, to tell SQL to insert 1000 records generating different unique ids but assign the constant values to the other columns?
Me with C#.net and sqlserver 2005. In my application there is a need to insert 1000 products details into my sqlserve table. I am using a for loop to insert and its done using a stored procedure, but when this code executes it stops mostly after 80 iterations and showing the error "Object reference not set to an instance of an object". How can I over come this? How can I make a steady sqlconnection?
View 12 RepliesI've just encountered an interesting problem in a standard BoundField in a GridView. The field is for EmployeeCode, which is purely numeric, but stored in a character column in the database. The DataFormatString="{0:00000}" attribute on the BoundField doesn't work, as I assume that format is only for numeric values.
To work around this, I had to use a TemplateField, and bind the text value using the attribute Text='<%# PadNumericString(Eval("EmployeeCode").ToString(), 5) %>'. Is there no simpler way of doing this?
Let's say we are building some public service that grabs the setup of a user (what server, user and pwd he wants to perform the call), logs in into that server and do some processing...
the process takes about 15 seconds to complete each user has a different setup (server/user/pwd), so the process needs to run against each one
if 1000 users tells the system to run the method at 1:00PM
How can I insure that the method is processed in the next 15 minutes?
What should be the correct approach to this little problem?
I'm thinking that I need to do something Asynchronously, and parallel processing could speed up things, maybe throttling the processes, maybe execute 100 calls per each 30 seconds?
I never did something like this and would love to get your feedback on ideas and future problems just to spend 100 hours of work and realize that I took a wrong road
In the code i have :
gvRankings.DataSource = rankings.OrderBy(rg => rg.Swimtime).Take(100).ToArray();
gvRankings.DataBind();
(Swimtime here is a timespan)
At the frontside i have
< asp:TemplateField HeaderText="Tijd" ItemStyle-CssClass="time" HeaderStyle-CssClass="smallheader">
< ItemTemplate><%# ("Swimtime")%>< /ItemTemplate>
< /asp:TemplateField>
I would like to format the swimtime like hh:mm:dd.ff but i have (after 2 hours of trying) absolutely no idea how to do this.....
I'm trying to take a querystring in string format and get the data out, like what would have been done with request.querystring("thefield")
I am submitting a form using ajax with this syntax:
var str = $("form").serialize();
$.post(url.....
So the serialized data posts to the controller fine, but I can't figure out how to deserialize the str value on the c# side. Guessing there is a better answer than writing a custom routine.
I have a program that is using credit card info and the expiration date is selected by the user clicking a dropdownlist for the month and a dropdownlist for the year. I want to show a label message if the user tries to proceed while the month and year are evaluated as being earlier that the current month/year.
View 4 RepliesI've completed the 22 first tutorials of the data access tutorials, and now I'm trying to apply these techniques to a project I started myself.But i'm stuck trying to replace an id by its value from another table, so I want to show all information about a car ("wagen") , but instead of showing "1" as driver ("chauffeur") I want to show his name.I've written this querry for the "wagen" table in the dal
[Code]....
I am using this line to pull out the date from a datareader linked to an sql statement.
PHP Code:
lbl_wall.Text = "<span style='font-size:12px;color:#555; font-style:italic'>Member since - " + String.Format("{0:ddd, MMM d, yyyy}", dbReaderPr["date_added"].ToString()) +"</span>";
The date format should be like:-
Quote:
"Sun, Mar 9, 2008"
But it appears like this:-
Quote:
"1/28/2010 8:00:16 AM"
How can i fix this?
When i write the following lines then i get an error like..
Input string was not in a correct format.
[code]....
i am taking string value from textbox name txtLastAppointment no. and want to convert it to int and then store it in databse using Linq to sql but i am getting error "input string was not in proper format" my Input string is 2.
My Code is.
objnew.lastAppointmentNo=Convert.ToInt32(txtLastAppointmenNo.Text);
I have the following get and sets
I am trying to do it so that my number is displayed in a currency format and British £.
However, I get an error in my GET when trying to run my website and it says ... 'Input string was not in a correct format'.
Can anyone see where I might be going wrong?
[Code]....
Consider this string 11/12/2010I need to convert this to 20101112.
View 2 RepliesI have a table in my SQL DB that is a DateTime table, what I want to do is take the numeric datetime it stores and convert it to a long date (i.e. 12/12/2012 conversts to December 12, 2012). Seaching the forums it looks like the string.format is the way to go and searching for info on that I found [URL] which lists all the different formats but they do not list a formating string to convert to the format I want to use. Does anyone know what format string I would use to convert a numeric date to a long date like I want? And can you show it in a code example because I am not 100% sure I understand the code examples shown on that site.
View 4 RepliesI am trying the following:
[Code]....
Where @Resource.Info is "{0} - {1}".
But I always get <p>0</p> - <p>1</p>.
I tried a few more options like using @<text>, @Html.Raw but I always end up with an exception or the same result.
Basically I have a localized resource, @Resource.Info, and I need to insert in the phrase some htm code.
I have below digits. I want to show one digit after to decimal. How to format it?
2.85
2
1.99
I was using ("{0:0.0}". But data showing like
2.9 //It should be 2.8
2.0 //It should be 2
2.0 //It should be 1.9