TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gabriel olayinka
NA
119
4.7k
can't save to database
Mar 31 2018 7:31 AM
i have a 2 tables in a database..... i'm retrieving record from one table, the insert the record into another table after changing some of the contents..... here is my code
void CreateRecord()
{
try
{
con.Open();
String sql = "SELECT STUD_ID, FNAME,LNAME,UNIQUE_REF,CLASSRM_ID from STUDENTS where CLASSRM_ID= '" + CLASSROOM_ID + "'";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (rdr.Read() )
{
STUD_ID = (int)rdr[0] ;
STUD_NAME =( rdr[1] + " " + rdr[2]).ToString();
UNIQUE_REF = rdr[3].ToString();
CLASSRM_ID = (int)rdr[4];
getSelectedSubjectID();
//this is the part that does the saving and its working fine
SaveAssessmentTemp();
}
}
finally
{
con.Close();
}
}//end CreateRecord
my problem is that ..... the last record in the (first table) which was retrieved into the datareader (rdr) is been saved twice..... how do i handle this?
Reply
Answers (
2
)
retrieving data from azure table and display in web app.
Simple Query please help