I want to print date when user give start date to end date period. if user give 3 month period then the date should print like
1/1/2011
1/2/2011
1/3/2011

This date print properly but I want to save that date in table. like the three dates are their so in the table three rows must be create. I tried to show that date in listbox because other controls shows only the last value how to save that date in table.

Please.......

Have you tried a DataGridView control?
It gives you the ability to store data (be it numbers, pictures or dates etc.) in rows and columns.
Look at this snippet for a very simple way how to do this.

there is no matter to display data i want to save that in a table i know how i show data in datagridview.

Every date must be save in a new row.

Do you mean a database table?
The word table has a lot of meanings I cannot directly understand in what context you are talking about a table.

i am sorry . Yes I want to save data in database table.

Sorry, I'm not so good with DBs. So I can not help you very much, but I'm sure there are some folks around here who can.

@Virusisfound
I can't able to understand you question, if you explain little bit more like from where the data to be fetch to save and as you mention the user enter the date period that is starting date and end date then from where you gate three date...........explain all these question to get help from me..........

I Have design a project for some installments. like i have take loan for 1 year then the first installment date is 1/1/2011 and end date is 1/12/2011. so i have print the date from first installment to last installment. in listbox.

now
I want to save that list in paricular table when that save then that can be display in datagridview . like

example Table:

Date Amount
1/1/2011 1023
1/2/2011 1023
1/3/2011 1023
1/4/2011 1023
1/5/2011 1023
1/6/2011 1023
1/7/2011 1023
1/8/2011 1023
1/9/2011 1023
1/10/2011 1023
1/11/2011 1023
1/12/2011 1023

when i try to save the dates that time entire data was not save only first or last date save in the database.

In short i want to know that how to save listbox items in database.

I hope you understand the problem.

Can you give me the table definition?

I can't understand. what do you want about table definition.

You have a daabase somewhere that you want to store this data in. In the database you define a table to hold information. How is that table defined (keys, columns, column ype, etc.)?

I have create table in databse with the name installments and the columns are number varchar(50) primary key, date datetime,amount numeric(20),account_name varchar(500)
This is my table columns.

I want to only save the dates and amount. but in new row.

@virusisfound

You need to be little precise and informative. It is nearly impossible to guess what is your database product (mysql or db2 or something else).

If you want to insert N records into a table then put your record insert code inside the loop.

DataSet ds = new DataSet();
 OleDbConnection cnn = new OleDbConnection();
 OleDbCommand cmd = new OleDbCommand();
 OleDbDataAdapter da = new OleDbDataAdapter();

cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\\mydatabase.mdb";
cnn.Open();
            cmd.CommandText = "select * from table1";
            cmd.Connection = cnn;
            da.SelectCommand = cmd;
            da.Fill(ds, "table1");
            int number = 0;          

                OleDbCommandBuilder cmb = new OleDbCommandBuilder(da);
                DataRow drow;
          for (; number <= listBox1.Items.Count-1; number++)
          {
              
                    drow = ds.Tables["table1"].NewRow();
                    drow["number1"] = number;
                    drow["datetime1"] = Convert.ToDateTime(listBox1.Items[number]);
                    ds.Tables["table1"].Rows.Add(drow);
          }
            da.Update(ds, "table1");
                MessageBox.Show("ONE RECORD IS ADDED.");
             cnn.Close();

don't use number,date as column name in this iam using ms access as a database........use this and feel free to ask any query.......
Best Of Luck

Thanks for reply. I don't under stand that how can I explain the details.
OK,
I have create my database in SQL 05 and front end is C# windows application. and I am glad that with out any details you send me code. I will run this code and tell you the output of this code. Thanks once again.

If your problem is solve then mark this thread to solve

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.