I have created an Exams form which has all its control(1 txtbox, 2 combobox) binded to exams table (SQL Database). The form has a Datagridview which shows two column, Subject and OutofMarks(dats total mark assigned to a subject e.g. Subject English is of 100 mark. The subject column of datagrid is derived from Subject table but has a reference in exam detail table (subject id). Both the column of Datagridview r combobox

My problem is dat i want to save values of form to exams table and the value of Datagridview to examdetail. I have used two sqlconnection (conn, conn1)to insert into both table... but the examId column of examdetail doesn't fill. :icon_rolleyes:

exam table has column(examId(PK),exam, examType,semId(FKey)
examDetail has column(examId(FKey),subjId(FKey),outOfmark)

I had even used a Tableadapter having values of both table but while using SELECT statement,it gave error as --> "invalid object" for Tableadapter

pls help with solution... :S
Thanx :)

hii prashant20,
no need to use two connection you can do this one connection like when you clik save button that time first save your Exam table data.

sqlconnection con =new sqlconnection("connection string");
sqlcommand cmd=new sqlcommand("your insert query",con);
Sqlcommand cmd=new sqlcomman("another insert query",con);
Messagebox.Show("Data inserted");
Catch(Exception ex)

Hello Prashant20,
Are you using DataSet? Can you give example of your code for this operation?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.