I am trying to teach myself a new language in three weeks. Can you please give me some advice on how to clean my code and make it faster or more reliable? This works fine. I don't "need" any 'free' code, I need the knowledge of what I am doing wrong, and what I am doing right so I can learn.
Using sqlCon = New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ITCSDatabase.mdf;Integrated Security=True")
Dim resultVar As String
sqlCon.Open()
Dim sqlText = "SELECT appLink FROM appTable WHERE Id = @name"
Dim cmd = New SqlCommand(sqlText, sqlCon)
cmd.Parameters.AddWithValue("@name", x)
resultVar = cmd.ExecuteScalar()
cmd.ToString()
If y = 1 Then
System.Diagnostics.Process.Start(resultVar)
ElseIf y = 0 Then
System.Diagnostics.Process.Start("iexplore.exe", resultVar)
Else
MsgBox("When calling the appCall Function, an invalid parameter is being sent in.")
End If
Dim sqlText2 = "UPDATE appTable SET appClickCount = appClickCount + 1 " & _
"WHERE Id = @x"
Dim cmd2 = New SqlCommand(sqlText2, sqlCon)
cmd2.Parameters.AddWithValue("@x", x)
cmd2.ExecuteNonQuery()
End Using