Click here to Skip to main content
11,702,396 members (68,709 online)
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 22:06pm
Edited 27-Feb-13 22:16pm
(no name)18.9K
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 Maciej Los 515
1 Sergey Alexandrovich Kryukov 355
2 OriginalGriff 299
3 CHill60 145
4 Mika Wendelius 115
0 OriginalGriff 8,369
1 Sergey Alexandrovich Kryukov 7,547
2 CPallini 4,922
3 Maciej Los 4,411
4 Mika Wendelius 3,556

Advertise | Privacy | Mobile
Web02 | 2.8.150819.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