Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

zasto ne upisuje u bazu mesece,dane i sate dobro?

[es] :: .NET :: zasto ne upisuje u bazu mesece,dane i sate dobro?

[ Pregleda: 2162 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

tomislav91

Član broj: 206601
Poruke: 316
*.dynamic.isp.telekom.rs.



+1 Profil

icon zasto ne upisuje u bazu mesece,dane i sate dobro?05.10.2014. u 09:40 - pre 115 meseci
evo ga taj deo koda koji sluzi za to pretrvaranje, gde je problem??? Ako izaberem danasnji dan i pre 5 nedelja on u bazi upise (ako u textBoxu izaberem 10 recimo random unosa), sve mesece u godini, a ne samo u tom periodu, dok godine uradi kako treba, ako stavim pre 5 godina i sad, samo mesece, dane i sate nesto ne funkcionise?

Code:

 //godina dtpOd
                    String aa = dtpOd.Value.Date.Year.ToString();
                    int aaInt;
                    aaInt = Convert.ToInt32(aa);
                    aaInt = int.Parse(aa);

                    
                    //godina dtpDo
                    String bb = dtpDo.Value.Date.Year.ToString();
                    int bbInt;
                    bbInt = Convert.ToInt32(bb);
                    bbInt = int.Parse(bb);

                    //random godine
                    Random r1 = new Random();
                    int randomYear1 = r1.Next(aaInt, bbInt);
                    Random r2 = new Random();
                    int randomYear2 = r2.Next(randomYear1, bbInt);

                    //random mesec i dan za dtpOd

                    int randomMonthNr1 = r1.Next(1, 13);
                    int maxDayNr1 = DateTime.DaysInMonth(randomYear1, randomMonthNr1);
                    int randomDayNr1 = r1.Next(1, (maxDayNr1 + 1));

                    //random mesec i dan za dtpDo
                    int randomMonthNr2 = r2.Next(1, 13);
                    int maxDayNr2 = DateTime.DaysInMonth(randomYear2, randomMonthNr2);
                    int randomDayNr2 = r2.Next(1, (maxDayNr2 + 1));

                    //random korisnici i dogadjaji
                    comboBox1.SelectedIndex = (new Random()).Next(comboBox1.Items.Count);
                    comboBox2.SelectedIndex = (new Random()).Next(comboBox2.Items.Count);

                    //random vreme
                    Random sat1 = new Random();
                    Random minut1 = new Random();
                    Random sekund1 = new Random();
                    int randomSati1 = sat1.Next(0, 24);
                    int randomMinuti1 = minut1.Next(0, 59);
                    int randomSekunde1 = sekund1.Next(0, 59);

                    Random sat2 = new Random();
                    Random minut2 = new Random();
                    Random sekund2 = new Random();
                    int randomSati2 = sat2.Next(randomSati1, 24);
                    int randomMinuti2 = minut2.Next(randomMinuti1, 59);
                    int a = 1;
                    int randomSekunde2 = sekund2.Next(randomSekunde1 + a, 59); //randomSekunde1 + 1, 59 ; ovo +1 da bude razlike u vremenima ako se desi preklapanje
                    //upis stringova za random unos
                    string s1 = "" + maxDayNr1 + "." + randomMonthNr1 + "." + randomYear1 + " " + randomSati1 + ":" + randomMinuti1 + ":" + randomSekunde1;
                    string s2 = "" + maxDayNr2 + "." + randomMonthNr2 + "." + randomYear2 + " " + randomSati2 + ":" + randomMinuti2 + ":" + randomSekunde2;



                    string tekstKomande = "insert into Tomislav (Korisnik, Dogadjaj, DatumOd, DatumDo) values('" + this.comboBox1.SelectedItem + "','" + this.comboBox2.SelectedItem + "','" + s1 + "','" + s2 + "') ;";



life is the one,take care of them!

http://hardware-software.serbianforum.info/
 
Odgovor na temu

ssi

Član broj: 305920
Poruke: 333
*.static.sbb.rs.



+377 Profil

icon Re: zasto ne upisuje u bazu mesece,dane i sate dobro?10.10.2014. u 12:28 - pre 115 meseci
Najsigurnije je da koristis:

Code:

 ODBC Canonical format = 'YYYY-MM-DD HH:MI:SS'


Sto bi znacilo:

Code:

INSERT INTO SOME_TABLE (SOME_DATE) VALUES ('2014-10-11 14:35:10')
GO
 
Odgovor na temu

[es] :: .NET :: zasto ne upisuje u bazu mesece,dane i sate dobro?

[ Pregleda: 2162 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.