Code:
id bigint Not Null Auto Increment subject nchar(32) Not Null chapter smallint Not Null type smallint Not Null question nchar(512) Not Null opt1 nchar(128) Not Null opt2 nchar(128) Not Null opt3 nchar(128) Null opt4 nchar(128) Null opt5 nchar(128) Null opt6 nchar(128) Null
Code:
connectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" dbCon = New SqlClient.SqlConnection(connectionString) sqlCom.Connection = dbCon sqlCom.CommandType = CommandType.Text sqlCom.CommandText = "INSERT INTO testDB(subject, chapter, type, question,opt1,opt2,opt3,opt4,opt5,opt6) VALUES(" + "'" + subject + "'" + "," & chapter & "," & type.ToString & "," + "'" + q + "'" + "," + "'" + op1 + "'" + "," + "'" + op2 + "'" + "," + "'" + op3 + "'" + "," + "'" + op4 + "'" + "," + "'" + op5 + "'" + "," + "'" + op6 + "'" + ")" Try dbCon.Open() sqlCom.ExecuteNonQuery() dbCon.Close() Catch ex As Exception End Try
Query runs successfully... But the record is not added... I have checked that there is no exception thrown by sql using the debugger....
dbCon.Open()
sqlCom.ExecuteN onQuery()
dbCon.Close()
Catch ex As Exception
these three lines execute and ex is not assigned anything...
Please help
Comment