Speed up this very short piece of SQL?
I have the following code in an XML Web Service, and need to speed it up a bit. It takes about half a second to complete, and its called about 17000 times in a row. Any thoughts?
VB Code:
<WebMethod()> Public Function UpdateProductInLocalDB(ByVal strDetails As String) As Boolean
Try
Dim strTemp() As String = Split(strDetails, vbLf)
Dim strSQLStatement As String, mySqlConnection As SqlConnection
If strTemp.GetUpperBound(0) = 12 Then
Dim strProductDetails = "'" & strTemp(0) & "', " & "'" & strTemp(1) & "', " & "'" & strTemp(2) & "', "
strProductDetails &= "'" & strTemp(3) & "', " & "'" & strTemp(4) & "', " & "'" & strTemp(5) & "', "
strProductDetails &= "'" & strTemp(6) & "', " & strTemp(7) & ", " & "'" & strTemp(8) & "', "
strProductDetails &= "'" & strTemp(9) & "', " & "'" & strTemp(10) & "', " & "'" & strTemp(11) & "'"
strSQLStatement = "DELETE FROM tblProducts WHERE strProductReference = '" & strTemp(0) & "';"
strSQLStatement &= "INSERT INTO tblProducts VALUES (" & strProductDetails & ");"
mySqlConnection = New SqlConnection(strConnectionString) : mySqlConnection.Open()
Dim mySQLCommand As New SqlCommand(strSQLStatement, mySqlConnection)
mySQLCommand.ExecuteNonQuery() : mySqlConnection.Close() : mySqlConnection = Nothing
Return True
Else
Throw New Exception("strTemp.GetUpperBound(0) != 12")
End If
Catch ex As Exception
ErrorLog(Now & vbCrLf & ex.ToString & vbCrLf & vbCrLf & strDetails & vbCrLf & vbCrLf & strConnectionString & vbCrLf & vbCrLf)
Return False
End Try
End Function