|
NAVNEETH,
that isnt the solution!!! when we use covert and datetime the sys will try to convert in mm/dd/yyyy format so if my returned date from database is in dd/mm/yyyy then it will throw an exception
dates which will throw error are: 13/03/2007, 22/01/1987, et etc
Gautham
|
|
|
|
|
gauthee wrote: I have a value returning from a database and that value is of datetime format dd/mm/yyy.
No, you don't. A datetime value doesn't have a format at all. Either you have a datetime value, or you have a string that represents a datetime value. As you are getting an error converting it to a datetime value, it has to be the later.
If possible, you should convert the data type in the database so that you are storing the datetime values as datetime values, not as strings.
Otherwise you have to specify the format when you are parsing the strings that you get from the database:
DateTime somewhereInTime = DateTime.ParseExact((string)objdr["startdate"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Hi
This will convert into format mm/dd/yyyy. But I dont have idea about convert this back to dd/mm/yyyy.
string StrDate = "13/03/2007";
DateTime dtmConvertDate;
IFormatProvider format = new CultureInfo("en-GB");
dtmConvertDate = DateTime.Parse(StrDate.ToString(), format, DateTimeStyles.None);
Response.Write("Date Format:" + dtmConvertDate.ToShortDateString());
Harini
|
|
|
|
|
Hey Gautham,
here is a simple way.
declare these variables first. just copy paste them.
string LocalTime = null;
DateTime dt;
DateTime local;
string localDateTime = null;
now, take the value from the database, and put the value in the variable LocalTime.
LocalTime = value(s) from the database ... should be a string value.
dt = Convert.ToDateTime(LocalTime);
local = dt.ToLocalTime();
localDateTime = string.Format("{0}/{1}/{2}", local.Month, local.Day, local.Year);
"put values in database" = localDateTime;
I hope its easy. get back to me if u dont understand
Keshav Kamat
India
|
|
|
|
|
Hello All,
i am using the following sql syntax in a sql command to drop a table if it exists.
DROP TABLE IF EXISTS TABLENAME
It should work fine in sql, but when i use this in a sql command, through C#, it gives me an error, saying there is a syntax error before IF.
could anyone help me? thanks in advance.
Keshav Kamat
India
|
|
|
|
|
I am not sure that we ca execute PL/SQL commands using commands object
|
|
|
|
|
we'll we can execute that command in a version of oracle in which i have worked before. Almost all the websites I checked give me the same query to check and accordingly delete the tables.
I have checked though that we cant use the if word in C#, for some reason.
I just want a way to drop tables if they exist directly through C# code.
i know how to create and drop, but to check and drop doesnt work out atleast for now
Keshav Kamat
India
|
|
|
|
|
I want to implement a dialog like the above examples when using MSDev. The dialog is docked in the left side of the application window and when hovered on top of shows the entire dialog, otherwise it's minimized. Any idea?
(Extra info: in this dialog I plan to implement a drop-down listbox and depending on which item in the list box is selected, a child window shows. (So yea the main app is a MDI and this MDI app is where this toolbar-type dialog will be docked).
Thanks in advance!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Hi All! I'm working on a windows service which polls a mailbox and retrieves mails through POP. Then it processes mails it retrieved from the server. Sometimes server stops responding in between the processing. I want to know how to gracefully stop the service and restart it. I've not worked with windows services prior to this, So I don't have much idea about it. Any help would be very much appreciated.
Thanks!
Don't Quit
|
|
|
|
|
TextFormat class allows you to justify a text to left, right, top, bottom, center and middle of the clip rect. But I saw in Microsoft Word an option to justify text to both margin, so every line of text has the same width.
I checked the TextFormat properties and didn't find out how to do this.
Please help me, thanks alot.
|
|
|
|
|
Help help help!
After searching the internet, I found nothing
|
|
|
|
|
I have been looking all over the MSDN area trying to find a listing of the various predefined methods (probally not the word I need).
My present interest in in things like Convert.DecToHex.Convert(). This is a static method from what I can find out. I'm trying to find what others are listed in this area and what they all do.
Does anyone happen to know where I might find this type of listing?
At this time I'm getting shunted to everywhere but where I want. My frustration factor is getting very high.
Thanks for any information you can get for me.
|
|
|
|
|
I am doing a project on C# 2005. I can't seem to retrieve data from my database. Can anyone please help me?
Table is called, ClientInfo with about 9 fields. I need to do a search from that table, and be able to display either in datagrid, or a listbox. I can't seem to find anything that could work, all i find is VB, and ASP.NET, but nothing helpful for C#. i sound desperate but the thing is I need this asap!
thanks in advance!
The slowest component sits at the keyboard.
|
|
|
|
|
Hi there,
Im still trying to figure out this csv reader thingy. I know this is a really simple thing im trying to acheive but as im still only a newbie with c# im finding it rather tricky. ive got the code that im using below, and it reads the csv just fine. the only problem im having is creating the array.
the csv is really simple to read. it just looks like
the amount of rows changes but the structure is the way it appears below.
123456,1234556,23434324,12313231,3423434234,4544354
123313,2312313,44545432,12323445,2424234322,2342334
I know this is a really simple dilemma but im sure one of you genius's can figure this out.
using System;
using System.IO;
class CSVReader
{
public static void Main()
{
try
{
string FileName = "FileImport.csv";
using (StreamReader sr = new StreamReader(FileName))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
|
|
|
|
|
Hi:
Using C#.NET form. I'm calling some external command line programm. I like to be able to capture output from command line. Could someone please help.
Thank you in advance for your help
Eyungwah
|
|
|
|
|
Take a look at the Process.StandardOutput property.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Do anybody knows how to display a parent-child relation in a winforms datagrid from a collectionbase-based custom object datasource.
the custom object looks like this:
public class ColeccionOT : System.Collections.CollectionBase
{
public ColeccionOT(){
}
public void Add(OT ot){
List.Add(ot);
}
public void Remove(OT ot){
List.Remove(ot);
}
public OT this[int index]{
get{return (OT)List[index];}
}
public object[] Items{
get{return InnerList.ToArray();}
}
}
--------
public class OT
{
private long _id;
private Proyecto _proyecto;
private System.DateTime _fechainicio;
private System.DateTime _fechafin;
private AdministradorOTBase _adminOT;
private ColeccionActividades _clcnActiv;
public OT() {
_clcnActiv = new ColeccionActividades();
}
public OT(AdministradorOTBase usuario, Proyecto proy) {
_clcnActiv = new ColeccionActividades();
adminOT = usuario;
proyecto = proy;
}
public ColeccionActividades Actividades {
get{return _clcnActiv;}
set{_clcnActiv = value;}
}
public long id{
get{return _id;}
set{_id = value;}
}
public Proyecto proyecto{
get{return _proyecto;}
set{_proyecto = value;}
}
}
parent object: ColeccionOT
child object: <<property>>OT.Actividades (another CollectioBase-Base object)
Thanks in advance.
PD. Sorry my bad english (I'm from germany)
|
|
|
|
|
Hello Guys:
how i can make color to active line in richtextBox ?
==============================================
see this image and u will know what i need
http://www.4zz.net/up/uploads/d69700664b.gif
==============================================
.:::thanks in Advance::.
|
|
|
|
|
RichTextBox richTextBox1 = new RichTextBox();
richTextBox1.BackColor = Color.Yellow;
richTextBox1.SelectionStart = 0;(starting point of text selected )
richTextBox1.SelectionLength = 4;( the number of characters selected )
richTextBox1.SelectionFont.Bold = true;
richTextBox1.SelectionStart = 9;(starting point of text selected )
richTextBox1.SelectionLength = 5;( the number of characters selected )
richTextBox1.SelectionFont.Bold = true;
|
|
|
|
|
hi,
richTextBox1.BackColor = Color.Yellow;
will make the entire richtextbox backcolor to yellow.
Instead of making perticular line or active cursor position.
with regards
prasad
|
|
|
|
|
Not work , i want make color to one line in richtextbox1(active line)
as this
http://www.4zz.net/up/uploads/d69700664b.gif[^]
i have idea but not work with me
1)test the cursor position
2)for the line where cursror is active make color to it
plz help me to do it
|
|
|
|
|
I have a byte array that contains all kinds of info.
Like
Bits Purpose
7-4 Color
...
15-9 Length
...
If this was my class
<br />
class BasePacket{<br />
private byte[] data;
....<br />
....<br />
}<br />
I like to be able do
<br />
<br />
BasePacket x = .....;<br />
x.color = 5;<br />
x.length = 3;<br />
int y = x.color;<br />
...<br />
...<br />
I know how to write this with &,|,<<, sets and gets but
I was wondering if there was a slicker solution.
I'd like to define each property on one line.
//Available bits
color , 4 , 4
length, 9, 7
<property name=""> , <bits start=""> , <bit length="">
Is this possible? I just looking for ideas not necessarily actual code.
Thanks for this great forum and its members.
|
|
|
|
|
I think BitVector32 [^] structure is along your way.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
string lowerCaseString = "converting case";
string upperCaseString = lowerCaseString.ToUpper();
string newLowerCaseString = upperCaseString.ToLower();
|
|
|
|