Function to Update is
Public Function UpdateSchool(ByVal procedurename As String) As Boolean
Dim flag As Boolean = False
Try
Dim sqlcon As SqlConnection = objDAL.Connection
Dim sqlcmd As New SqlCommand(procedurename, sqlcon)
sqlcmd.CommandType = CommandType.Text
sqlcmd.Parameters.AddWithValue("@SchoolID", SID)
sqlcmd.Parameters.AddWithValue("@SchoolName", Me.Txt_Fname.Text)
sqlcmd.Parameters.AddWithValue("@Address", Me.Txt_Add.Text)
sqlcmd.Parameters.AddWithValue("@City", Me.txtCity.Text)
sqlcmd.Parameters.AddWithValue("@State", Me.txtState.Text)
sqlcmd.Parameters.AddWithValue("@Contact1", Me.Txt_Ph.Text)
sqlcmd.Parameters.AddWithValue("@Contact2", Me.Txt_Ph.Text)
sqlcmd.Parameters.AddWithValue("@EmailID", Me.Txt_Mail.Text)
sqlcmd.Parameters.AddWithValue("@Website", Me.txtWebsite.Text)
sqlcmd.Parameters.AddWithValue("@Remarks", Me.Txt_Vat.Text)
sqlcon.Open()
Dim rowaffected As Integer = sqlcmd.ExecuteNonQuery()
sqlcmd.Dispose()
sqlcon.Close()
MsgBox("School Information is Updated Successfully", MsgBoxStyle.Information + MsgBoxStyle.Information)
flag = True
Return flag
Catch ex As Exception
MsgBox(ex.Message)
'MsgBox("School Information is not Updated Successfully. Please Try Again", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Return flag
End Try
End Function
Command/Event to update is
Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinish.Click
Dim str As New StringBuilder
str.Append(validated.Validate(Txt_Fname, True, validated.StringAll, "SchoolName"))
If str.Length <> 0 Then
MessageBox.Show(str.ToString())
Return
End If
Dim str1 As New StringBuilder
str1.Append(validated.Validate(txtWebsite, False, validated.StringAll, "Website"))
If str1.Length <> 0 Then
MessageBox.Show(str1.ToString())
Return
End If
Dim str2 As New StringBuilder
str2.Append(validated.Validate(Txt_Vat, False, validated.StringAll, "Remarks"))
If str2.Length <> 0 Then
MessageBox.Show(str1.ToString())
Return
End If
Dim str3 As New StringBuilder
str3.Append(validated.Validate(Txt_Mail, False, validated.EmailAddress, "Email"))
If str3.Length <> 0 Then
MessageBox.Show(str3.ToString())
Return
End If
Dim str6 As New StringBuilder
str6.Append(validated.Validate(Txt_Add, True, validated.StringAll, "txtAddress"))
If str6.Length <> 0 Then
MessageBox.Show(str6.ToString())
Return
End If
UpdateSchool("Update tbSchoolInfo set [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected] where [email protected]")
MainForm.LoadSchoolInfo()
RefreshGrid()
frmSelect.Show()
Me.Close()
End Sub

New Topic/Question
Reply


MultiQuote


|