Hi,
The following code executes without error but refreshing the database record not inserted. It does tell me that 'New Tenant has been added'
At the start of the Dub I have:
Where am I doing wrong ?
Thanks,
The following code executes without error but refreshing the database record not inserted. It does tell me that 'New Tenant has been added'
Code:
Dim command As New SqlCommand("INSERT INTO dbo.tbltenants (firstName, lastName, tenantfullname, telephone, email, nationalid, copyID) VALUES (@firstName, @lastName, @tenantfullname, @telephone, @email, @nationalid, @copyID)", conn)
Dim ms As New MemoryStream
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
command.Parameters.Add("@firstname", SqlDbType.VarChar).Value = TxtFName.Text
command.Parameters.Add("@lastname", SqlDbType.VarChar).Value = TxtLName.Text
command.Parameters.Add("@tenantfullname", SqlDbType.VarChar).Value = TxtFName.Text & " " & TxtLName.Text
command.Parameters.Add("@telephone", SqlDbType.NVarChar).Value = TxtTel.Text
command.Parameters.Add("@email", SqlDbType.NVarChar).Value = TxtEmail.Text
command.Parameters.Add("@nationalID", SqlDbType.NVarChar).Value = TxtNationalID.Text
command.Parameters.Add("@copyID", SqlDbType.Image).Value = ms.ToArray()
' cmd.ExecuteNonQuery()
'Catch ex As Exception
' MsgBox(ex.Message, MsgBoxStyle.Information, "RCMS")
'End Try
MsgBox("New Tenant has been added", MsgBoxStyle.Information, "RCMS")
Me.Close()
End If
conn.Close()
conn.Dispose()
End Sub
Code:
Dim conn As SqlConnection = GetDbConnection()
Dim query As String
Dim cmd As New SqlCommand
Thanks,