Click here to Skip to main content
Rate this: bad
good
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
(no name)17.7K
v2
Comments
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 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2014
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