Start by fixing the
SQL Injection[
^] vulnerability in your code:
Public Shared Function addDataUsingAdepter(id As Integer, Name As String, photoFilePath As String, Description As String, type As String) As Boolean
Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString
Dim query As String = "insert into Products values (@id, @Name, @photoFilePath, @Description, @dt, @type)"
Try
Using conn As New SqlConnection(ConnectionString)
Using cmd As New SqlCommand(query, conn)
cmd.Parameters.AddWithValue("@id", id)
cmd.Parameters.AddWithValue("@Name", Name)
cmd.Parameters.AddWithValue("@photoFilePath", photoFilePath)
cmd.Parameters.AddWithValue("@dt", DateTime.Now)
cmd.Parameters.AddWithValue("@type", type)
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
Return True
Catch ex As Exception
MsgBox(ex.ToString())
Return False
End Try
End Function
That will almost certainly fix the issue. If not, you'll need to post the details of the error you're getting.