|
Thank you. Have a great weekend.
|
|
|
|
|
How will the user enter the data? Are you using WinForms? If so, you could just use a DatePicker Control and set the format however you want
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The users are enter data in a datagrid view on a winform.
|
|
|
|
|
Maybe try something like this...
DateTime dt = DateTime.Now;
if(DateTime.TryParseExact("DATEVALUE", "MM/dd/yy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt))
{
DataGridViewCell.Value = dt.ToString("MM/dd/yyyy");
}
else if(!DateTime.TryParseExact("DATEVALUE", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt))
{
}
NOTE 1: you could add some logic here to test if the year is 20 but I would suggest you leave trying not to allow it to be converted to 2020 as that is what should be expected, plus if you validate each cell when it has lost focus then the user will see the change and can edit if it is wrong
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
PIEBALDconsult wrote: It is my firm belief that the DataGrid(View) was developed solely to demonstrate the power of ADO.net and should never be used in a production application.
Have 5, I want to form a club - those who refuse to use a DGV for editing.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks, I don't get many.
|
|
|
|
|
Your 2 most useful responses are from Ennis - use a datetime picker and Piebald - DON'T USE A DGV FOR EDITING, pop a dialog and let the user edit in the dialog (using the datetime picker).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Ive created an application using c# vs2008 and sql server 2005
on my pc everything works fine, but when i release it onto a server it has trouble connecting to the database.
Im using Linq - ive created a DataLinq project, a DataAccess project and a BusinessLogic project...
For the Linq project i simply added a dbml file, dragged all the necessary tables across and voila...
If I do a search for 'connectionString' in the DataLinq project - it appears in a number of places with the actual value hard coded - its in:
app.config
bin\Debug\DataLinq.dll.config
DBLinq.dbml
Settings.Designer.cs
Settings.settings
I would expect it in the app.config file - am I expected to change it in all the locations before release or am i doing something wrong?
Cheers,
Chas
|
|
|
|
|
Just app.config will be enough!
bin\Debug\DataLinq.dll.config is a copy of app.config made by VS on build success.
application settings are written to the app.config as well (in settings you can choose application or user)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I add two splitconrainers. The panel at the topmost will have a problem. The top region of Panel will be covered by toolstrip. But I woudl to draw some thing like pixture to fill the Panel. How do I modfy this problem to prevent the panel covered by toolstrip?
http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/Visual%20C%7C3/VC%7C3%7C_spliContainer%7C_dosck%7C_region.jpg
You can the jpg file, the top region of the topmost panel is covered with toolstrip.
|
|
|
|
|
Hi,
Is this just a problem with the way you have constructed the form in the designer? With docking controls you really need to start at the outside and work in towards the middle.
1) Form
2) menu strip
3) tool strip
4) split container.
Alan.
|
|
|
|
|
When this sort of thing happens, simply right-click on the control that is partly hidden and from the context menu that appears click Bring To Front.
Problem Solved!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi,
I m using MS-Index Services, everything doing well
But i want to Retrieve Office Document(doc,xls)html etc Metadata
means some text area just like google web site Result.
somebody help me for configuration and query for retrieve documents text part.
|
|
|
|
|
I want to remove the http response header using regular expression
for example the following is the response i get
-----------------------------------------------
HTTP/1.1 200 OK
Date: Fri, 07 Aug 2009 18:10:29 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8
X-Powered-By: PHP/5.2.8
Content-Length: 140
Connection: close
Content-Type: text/html
A Word a Moment
Word : somber
Pron : sombu(r)
Meaning :
1. Lacking brightness or colour; dull
Example : (empty)
---------------------------------------------------
and i need only the text after "A word a moment"
so i thought of this code which is not as expected
string outs = Regex.Replace(cont, "^.*\r\n\r\n", "", RegexOptions.Multiline);
what could be the pattern to remove the http response header so that i can just use the actual response?
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
I think it would be easier for you if you don't use a regexp. You can simply drop all the header, directly when reading from the socket's stream.
If you can only have the full text in a string (for example if you are using a third-party library and cannot modify the code which reads from the socket), then you can parse it and find the beginning of the text you need.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
sure. but i thought i can include the knowledge of using regex with win32. actually i already have a program written in win32 api which is working well. in that i used strpos to find the two \r\n\r\n to find the end of the response header. coding in win32 api to accomplish my need gets tedious so i am writing the same program in c#. instead of the old way i thought of trying new. anyway do you know how to read the response body using any of System.Net.Sockets ? ... and the program is here ... http://vikku.info/wordreminder/[^]
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
Ok I see. Well, if you want to use regexps, the easiest way I can think of is something like:
string HttpText = "HTTP/1.1 200 OK\r\nDate: Fri, 07 Aug 2009 18:10:29 GMT\r\nServer: Apache
/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimi
ted/1.4 FrontPage/5.0.2.2635 PHP/5.2.8\r\nX-Powered-By: PHP/5.2.8\r\nContent-Length: 140\r\
nConnection: close\r\nContent-Type: text/html\r\n\r\nA Word a Moment\r\nWord : somber\r\n\r
\nPron : sombu(r)\r\n\r\nMeaning :\r\n1. Lacking brightness or colour; dull\r\n\r\nExample
: (empty)\r\n\r\n";
Regex MyRegex = new Regex("\r\n\r\n");
String[] MyStrings = MyRegex.Split(HttpText, 2);
if (MyStrings.Length != 2)
{
throw new ApplicationException("Error parsing HTTP response!");
}
Console.WriteLine("Header:");
Console.WriteLine("-------");
Console.WriteLine(MyStrings[0]);
Console.WriteLine("Body:");
Console.WriteLine("-------");
Console.WriteLine(MyStrings[1]);
Console.WriteLine("-------");
But it doesn't make much sense to use the Regex object here, since the pattern separating header from body is a fixed string ("\r\n\r\n"), so the same can be done using String.Split() , which is simpler and more performing.
If you want to use Regex.Replace() , like in your example, then you will have to limit the number of matches to replace to one, otherwise ALL matches will be replaced with the empty string! See the docs here[^].
Regarding how to read data from a socket, if you check the docs for objects in System.Net.Sockets , like TcpClient[^], you'll see they expose methods to obtain a NetworkStream[^], which you can use to read data.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Excellent. thank you for your needful reply. the tcpclient will help for now and also i will tinger with the others. i had a quick view of your links and i have to spend more time on that.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
My pleasure, good luck.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Hello,
I am creating a GUID and then using that ID inside a SQL statement. I get an error saying that incorrect syntax near '-' , and I believe its referring to the dashes that are created with the GUID. So i was going to split up the GUID and just make it a string of characters. Can anyone help me do this? BElow is a little bit of code to show how I'm using it. Thanks for your help!
SqlConnection sqlConn = new SqlConnection("Data Source=localhost;Initial Catalog=Cost_Model;Integrated Security=True");
sqlConn.Open();
System.Guid UID = System.Guid.NewGuid();
Int16 SCENARIOID = 1;
SqlCommand sqlComm1 = new SqlCommand(
"INSERT INTO web_far15 select " + UID + ", * from fn_far15(" + SCENARIOID + ")",
sqlConn);
SqlDataReader r = sqlComm1.ExecuteReader(CommandBehavior.CloseConnection);
Session["TableName"] = "web_far15";
Session["SessionID"] = UID;
r.Close();
Thanks again for your help!
|
|
|
|
|
Ummm... what? If you provide the GUID as a string SQL Server will parse it.
SELECT * FROM table WHERE ID='blah-blah-blah...'
I don't know whether or not other databases will.
But you'd have an even easier time using a parameterized statement.
|
|
|
|
|
All I did to get the GUID was
System.Guid UID = System.Guid.NewGuid();<code> which created the code.<br />
<br />
When I try to pass the GUID directly it does not allow it, I get the '-' error explained above. Its also not letting me typecast it to a string.
|
|
|
|
|
Parse it with what? Why do you need to parse it?
System.Guid has a constructor that will do it. SQL Server will do it. But you shouldn't need to do it at all.
|
|
|
|
|
I believe I need to parse it so I can take out the dashes. When I run the code, I get the error "Incorrect syntax near '-'." and it breaks at SqlDataReader r = sqlComm1.ExecuteReader(CommandBehavior.CloseConnection);
So when I read that, that sounds like I need to take out the dashes. Am I incorrect?
|
|
|
|