|
As darklev pointed out, your base error is if you are storing your dates as a string. If you are using a database then you MUST use the date data type to store your data. If you persist in using a string to store the date your will never be free of the formating problem.
|
|
|
|
|
i have couple of csv files, some are comma separated, some tab separated, some are unicode and some are ansi.
what is the easiest way to find out what delimiter the file uses and its encoding.
thank you.
|
|
|
|
|
what do you mean by easiest ????
You want to know the delimeter/unicode with out opening the csv file.
??????????
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
no. maybe ill rephrase the question..
how do i do it ??
|
|
|
|
|
Haimbert wrote: what is the easiest way to find out what delimiter the file uses
Asking the user what it is.
Beyond that, you have to analyze the file to determine what the most likely delimeter is. You'd have to ask the user if the delimiter you've figured out is actually correct.
Haimbert wrote: what is the easiest way to find out ... its encoding.
This is generally impossible to determine reliably. But, the StreamReader class can attempt to figure out what the encoding is, but there is no guarantee it's going to be correct. Again, asking the user if what has been determined as most likely correct is the only way to be sure.
|
|
|
|
|
Hi,
1.
open the file and see if you can read it; you might use File.ReadAllLines for this.
most formats (e.g. UTF8) have some byte codes in front to indicate what encoding they are
using (look with a hex editor for 0xFF 0xFE or 0xFE 0xFF), so the system has a good chance
of reading them correctly by default.
2.
if you expect no comma's in fields and you find a comma, then comma is the delimiter.
same for tabs.
if you expect both to be possible, then you need two passes:
in the first pass, count comma's and tabs; the most popular will be the delimiter.
in the second pass, process the data.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello,
I am making an application which can control a pabx (telephone switch).
I connect my pc and the pabx via com port.
For the connection setup i have to send some characterlines to the pabx.
Sending normal ascii characters works fine. I use:
SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3))
However, i have to send also hex97 (for example).
Is there someone who can give me some information.
I guess i have to change the character set? But how?
Regards,
Bas
modified on Saturday, April 5, 2008 6:12 AM
|
|
|
|
|
Send Ascii value insted if Hexcode
example
i want to sent " charachter
SerialPort.WriteLine(Chr(34))
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hello Rajesh,
Thanks for your answer.
I tried but when i send the character instead of Hex then i stil have to use an other character set, because hex97 = character 151. Standard ascii set starts at 0 and ends at 127. Extended ascii character set starts at 128 and ends at 255. As i have to send hex97 or character 151 i guess i have to change the character set but i do not know how and to which character set.
Regards,
Bas
|
|
|
|
|
try with ChrW() insted of Chr()
reply me...
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
I tried, but it doensnt work
|
|
|
|
|
first check u r encoding of serial port
set below encoding for UTF-8 support
SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1252)
after try this code
Dim mybyte As Byte = 150
serialport.write(mybyte )
i think it will work
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hello Rajesh,
Thanks a lot, this works fine.
I have been working for at least two weeks on this problem and now within two hours you solved my problem.
Regards,
Bas
|
|
|
|
|
Welcome
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
keninfo wrote: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3))
However, i have to send also hex97 (for example).
So what's wrong with writing Chr(&h97) ??
|
|
|
|
|
Hi,
if you need to send special byte values over SerialPort, forget about text, strings and
encodings, and use SerialPort.Write, which works with byte arrays, no encoding, no
translation. What you get is what you ordered.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi,
I have 1 server, I using VB.NET to create folder, so can i do?
Thanks
Socheat
|
|
|
|
|
Q. not clear
I have 1 server, I using VB.NET to create folder, so can i do?
????????????????????? ???????????????? /////////
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Using the Directory class, just like you would with a local path using a drive letter specification. The path will change to a UNC format.
I hope you've brushed up on your Windows Networking skills.
|
|
|
|
|
Hi friends,
where can I download Microsoft.DirectX.Direct3DX for free? Thanks.
Cheers,
Joy Anne
|
|
|
|
|
The DirectX SDK can be found here[^]. Warning: Visual Basic.NET documentation and samples were removed a couple of years ago. All code samples are going to be in C# or C++.
|
|
|
|
|
I am unable to show data on datagridview using the following code.
Can anybody help me please. Nothing showing in datagridview but no error message displayed.
Suman
Dim str As String
Dim mycon As New OleDb.OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim dv As New DataView
str = "Provider=Microsoft.jet.oledb.provider.4.0; Data
Source=Nwind.mdb;"
mycon.ConnectionString = str
mycon.Open()
str = "select * from customers"
da = New OleDbDataAdapter(str, mycon)
da.Fill(ds)
DGV.DataSource = ds.DefaultViewManager
|
|
|
|
|
hi,
if dataset contains data(verify it in debug mode) , then
try this code
DGV.DataSource = ds.Tables(0)
in place of
DGV.DataSource = ds.DefaultViewManager
hop this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Sorry, it is not working. Should I change any properties to show data?
Suman
|
|
|
|
|
hi suman,
there r no mistake in code.
are you sure, query return some records ? Verify it in debug mode
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|