ID DD MM YYYY Hour : Minute (In/Out)
0000042003 27 08 2008 09 38 I
0000042003270820080938I
0000042003270820080939O
The data above I got from swipe card time machine for employee clock in-out .
How can I import to database ( I expect to use the sql server 2008 )
and how to the table should be.
Programmer please teach me please.
Loading
natchaya khamkunaPosted Jun 7, 2011, 4:03 AM
Sam HobbsPosted Jun 6, 2011, 11:10 PM
Joao KiewelPosted Jun 6, 2011, 4:20 PM
The main advantage of the schema.ini file is that you don't need to define these fields in your application and avoid many unnecessary exception treatment.
Sam HobbsPosted Jun 5, 2011, 2:52 AM
There are many ways to do it. The following is a sample of one way to read the input. There is a lot more to be done; you need to learn how to use databases. Start by reading some of the articles in this web site about database programming and then when you have specific questions ask for help with that in a new thread in one of these forums. For the database part you probably want to use ADO .Net so you should ask questions about that in the ADO .Net forum.
using System.IO;
namespace _125812
{
class Program
{
static void Main(string[] args)
{
String Buffer;
String id;
int year, month, day, hour, minute;
DateTime dt = new DateTime();
char io;
// you must change the filename in the StreamReader
using (StreamReader sr = new StreamReader(@"Data.txt"))
{
while (!sr.EndOfStream)
{
Buffer = sr.ReadLine();
id = Buffer.Substring(0, 10);
day = ConvertNumber(Buffer.Substring(10, 2));
month = ConvertNumber(Buffer.Substring(12, 2));
year = ConvertNumber(Buffer.Substring(14, 4));
hour = ConvertNumber(Buffer.Substring(18, 2));
minute = ConvertNumber(Buffer.Substring(20, 2));
io = Buffer[22];
dt = new DateTime(year, month, day, hour, minute, 0);
Console.WriteLine("{0} {1} {2}", id, dt, io);
}
}
}
static int ConvertNumber(String text)
{
int i;
// Int32.TryParse returns true if the text was converted to a number
if (Int32.TryParse(text, out i))
return i;
Console.WriteLine("Invalid data: {0}", text);
return 0;
}
}
}
natchaya khamkunaPosted Jun 4, 2011, 7:51 AM
Sam HobbsPosted Jun 3, 2011, 6:25 PM
The next thing to know is if you can use a SQL Server utility to import the data or if it needs to be done in a program.