Maybe your connection is already open. You should replace con1.Open()with this: If con1.State <> ConnectionState.Open Then con1.Open() End If Also, you should put a Finally block on your try catch, and close the connection after you run an ExecuteNonQuery or an ExecuteScalar. You can use something similar to how you open it, like this: If con1.State <> ConnectionState.Closed Then con1.Close() End If Some other things I noticed in your code...you're importing sqlclient, but you are not using it, so you probably don't need to import it (unless you are using it in code that you didn't post) Also, you declared a dataadapter object, but you are not using that either (again, unless you just didn't post it)...you also might want to look at disposing objects when you are done with them. For example, once you've used the command object at the end of you function, you could dispose it. Hope this helps.