1 Replies - 20121 Views - Last Post: 03 May 2007 - 12:11 AM Rate Topic: -----

#1 monster rachel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-May 07

Insert Date into DBase IV (.DBF) by using C#.net

Posted 02 May 2007 - 08:37 PM

Hello,
I have a problem when i insert a new record into DBASE DBF file by using C#. I was wondering is it because of the "date" causing the problem. Could anybody help me? Thanks.

Here is my configuration file setting for DBASE:
<connectionStrings>
<add name="DBASEInstance"
providerName="System.Data.OleDb"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=D:\Loading\bin\Debug\FMISLoading Data; Extended Properties=dBASE IV"/>
</connectionStrings>

	  //constructor
	  static DAL()
	  {	   
		  dbDBase = DatabaseFactory.CreateDatabase("DBASEInstance");				
	   } 

	   public static void InsertDataIntoDyEmpDataDBF()
	   {
			string SQLInsert_DYEMDATA =
			"insert into DYEMDATA (MOVER_NO,  WRK_DATE, EMP_NO) " +
			"values ('{0}', {1}, '{2}')";

			DataSet dsDyEmpData = GetItemTransaction();
			foreach (DataRow drDyEmpData in dsDyEmpData.Tables[0].Rows)
			{
				string vProdGroup = drDyEmpData["PRODGROUP"].ToString();
				DateTime vLogdate = Convert.ToDateTime(drDyEmpData["LOGDATE"]);			
				string vEmpNo = drDyEmpData["EMPLOYEENO"].ToString();
				
				string SQLInsertDyEmpData = 
				string.Format(SQLInsert_DYEMDATA, vProdGroup, vLogdate, vEmpNo);

				DbCommand cmd = dbDBase.GetSqlStringCommand(SQLInsertDyEmpData);
				dbDBase.ExecuteNonQuery(cmd);
			}
		}



Is This A Good Question/Topic? 0
  • +

Replies To: Insert Date into DBase IV (.DBF) by using C#.net

#2 JellyBean  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 60
  • Joined: 25-April 07

Re: Insert Date into DBase IV (.DBF) by using C#.net

Posted 03 May 2007 - 12:11 AM

Have you tried formatting the date like this:

yyyy-MM-dd hh:mm:ss

For example, my time now would be '2007-05-03 08:07:00'

This usually works for me when inserting a DateTime value into a SQL db.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1