Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# database DataGrid
Sch_Date SJ (Facultycode)
25/2/2013 ARPA / MFA (Coursename)
i want to save in the database as follows;
Sch_Date Facultycode Coursename
25/2/2013 SJ ARPA
25/2/2013 SJ MFA
Save code as follows;
        sql = "insert into Tb_SCh_TIme_Table([Sch_Date], [Course],[Faculty_Code])" + " values ('" + Convert.ToDateTime(datagridView.Rows[i].Cells[0].Value.ToString()) + "',  '" + datagridView[j, i].Value.ToString() + " / " + datagridView[j,i].Value.ToString () + "','" + datagridView.Columns[j].HeaderText.ToString() + "')";
using the above code to save in database,
in database save as follows;
Sch_Date Facultycode Coursename
25/2/2013 SJ ARPA / MFA
but i want the ouput as follows
Sch_Date Facultycode Coursename
25/2/2013 SJ ARPA
25/2/2013 SJ MFA
please help me how can i do using csharp.
Note it is windows application.
Posted 27-Feb-13 23:06pm
Edited 27-Feb-13 23:16pm
CHill60 at 28-Feb-13 6:13am
You need to clarify your question. From the code you've posted you look to be saving the course name twice with a '/' between
datagridView[j, i].Value.ToString() + " / " + datagridView[j,i].Value.ToString ()
But I think you are saying that datagridView[j,i] contains text "ARPA / MFA" ?
But you want this on the data base as two separate rows - one for ARPA and another for MFA?
Member 8054539 at 28-Feb-13 7:28am
in database i want to save as follows;
Sch_Date Faculty_code CourseName
25/2/2013 SJ ARPA
25/2/2013 SJ MFA
i want to save the two course for the same faculty_Code.
how can i split it up and save in the database.
how can i write the code to save the two course split up and save it in the database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 719
1 CHill60 240
2 Sergey Alexandrovich Kryukov 220
3 TheRealSteveJudge 220
4 CPallini 200
0 Sergey Alexandrovich Kryukov 9,078
1 OriginalGriff 6,771
2 Peter Leow 4,282
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,661

Advertise | Privacy | Mobile
Web02 | 2.8.150128.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100