hey all, I currently have this insert statement:

OleDbConnection oledbConnectionGate = new OleDbConnection(OLEDB_CONNECTION_STRING);

            string TRANSACTION_INFO_INSERT_STATEMENT = "INSERT INTO Transaction" +
            "([TransactionID], [TransactionAuditor_ID], [TransactionAuditor_Name], [TotalSales], [TransactionDate])" +
            "VALUES (?,?,?,?,?)";

            OleDbCommand commandLine = new OleDbCommand(TRANSACTION_INFO_INSERT_STATEMENT, oledbConnectionGate);

            
            commandLine.Parameters.Add("TransactionID", OleDbType.BigInt, 64).Value = currentTransaction.TransactionID;
            commandLine.Parameters.Add("TransactionAuditor_ID", OleDbType.BigInt, 64).Value = currentTransaction.TransactionAuditorID;
            commandLine.Parameters.Add("TransactionAuditor_Name", OleDbType.VarWChar, 255).Value = currentTransaction.TransactionAuditorName;
            commandLine.Parameters.Add("TotalSales", OleDbType.Double, 64).Value = currentTransaction.TotalPrice;
            commandLine.Parameters.Add("TransactionDate", OleDbType.DBTimeStamp, 60) = currentTransaction.TransactionDate.ToString("G: {0:G}", currentTransaction.TransactionDate);

            oledbConnectionGate.Open();
            commandLine.ExecuteNonQuery();
            oledbConnectionGate.Close();

now my problem is I don't know how to store the transaction date to my oledb database. I have set the format of the date in my oledb database to "general" (i.e. mm/dd/yy hh/mm/ss PM or AM). Now what I can't get is how do I cast my datetime value to that general format..

here is my class containing that datetime value:

public class Transaction
    {
        private static long currentTransactionID;
        private static bool isFirstInstantiation = true;

        private const int DEFAULT_NUMERICAL_VALUE = 0;
        private const string DEFAULT_STRING_VALUE = "";

        private List<Order> orderList;
        public List<Order> OrderList
        {
            get { return this.orderList; }
            set { this.orderList = value; }
        }

        private double totalPrice;
        public double TotalPrice
        {
            get { return this.totalPrice; }
            set { this.totalPrice = value; }
        }

        private long transactionID;
        public long TransactionID
        {
            get { return this.transactionID; }
            set { this.transactionID = value; }
        }

        private long transactionAuditorID;
        public long TransactionAuditorID
        {
            get { return this.transactionAuditorID; }
            set { this.transactionAuditorID = value; }
        }

        private string transactionAuditorName;
        public string TransactionAuditorName
        {
            get { return this.transactionAuditorName; }
            set { this.transactionAuditorName = value; }
        }

        private DateTime transactionDate;
        public DateTime TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }


        public Transaction()
        {
            this.TotalPrice = DEFAULT_NUMERICAL_VALUE;
            this.TransactionAuditorID = -1;
            this.TransactionID = -1;
            this.TransactionAuditorName = DEFAULT_STRING_VALUE;
            this.OrderList = new List<Order>();
            this.TransactionDate = System.DateTime.Now;
        }

        public Transaction(List<Order> orderList, Employee currentAuditor)
        {
            this.OrderList = orderList;
            this.TotalPrice = DEFAULT_NUMERICAL_VALUE;
            this.TransactionAuditorID = currentAuditor.EmployeeID;
            this.transactionAuditorName = currentAuditor.EmployeeName;

            if ((isFirstInstantiation) && (currentTransactionID != 0))
            {
                currentTransactionID = 1;
                isFirstInstantiation = false;
            }

            else
            {
                currentTransactionID += 1;
            }

            this.TransactionDate = System.DateTime.Now;
        }

        public double GetTotalPrice()
        {
            for (int i = 0; i < orderList.Count; i++)
            {
                this.totalPrice += orderList[i].GetOrderPrice();
            }

            return this.totalPrice;
        }

        
    }

I also do not know how to format that date time value in my class but gave a shot at it by placing the system.datetime.now value for my constructors. This class will be used to store these values when I am going to write them to the oledb file and when I am going to read the data from the oledb file back to my program. But what I know is that the format for the datetime.now is mm/dd/yy hh/mm/ss PM or AM so I know I do not need any more type casting when I am going to write the stored value in the transaction date to the database. I am only storing the date for each transaction so that format will always be used. I just can't store it, and I also am having trouble determinging how am I going to read that date time from the oledb to my program.

Help will be greatly appreciated. Thankyou.

>Format for storing and reading date time to oledb

Check the regional settings (Control panel).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.