hi...
i have one problem in my programming using vb.net...
i want to insert data into database, using multiple condiction (if else statement)...
before it save, it check wheather the matrix no and date already save in database or not.
the condiction is in one date only one report is allow, this is only one student
this is my code:
Protected Sub btn_save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_save.Click
Dim srcAdd As New SqlDataSource()
srcAdd.ConnectionString = ConfigurationManager.ConnectionStrings("Connection String").ToString()
srcAdd.InsertCommandType = SqlDataSourceCommandType.Text
srcAdd.InsertCommand = "INSERT INTO Report ( Date, Report, NoMatrix ) Values (@Date, @Report, @NoMatrix)"
srcAdd.InsertParameters.Add("Date", txt_date.Text)
srcAdd.InsertParameters.Add("Report", txt_report.Text)
srcAdd.InsertParameters.Add("NoMatrix", txt_NoMatrix.Text)
Dim rowsAffected As Integer = 0
Try
rowsAffected = srcAdd.Insert()
Catch ex As Exception
Finally
srcAdd = Nothing
End Try
If ((txt_NoMatrix.Text = "@NoMatrix") And (txt_date.Text = "@Date")) Then '(this code does't work)
MsgBox("SAVE FAILED! You alredy use this date !", MsgBoxStyle.OkOnly, "RESULT")
Response.Redirect("view_report.aspx")
Else
MsgBox("SAVE SUCCESSFULL!", MsgBoxStyle.OkOnly, "RESULT")
Response.Redirect("view_report.aspx")
End If
End Sub
please help me...