Skip to content
Advertisement

Sql Command Not Working

I wrote the following code, but nothing is being inserted into the database.

I tried changing the SA password in the connection string to something incorrect and the code isn’t catching the exception.

What am I doing wrong?

Advertisement

Answer

As stated by the OP in the comments. Once the try-catch was resolved it was discovered that it just a mismatched number of fields and values.

Just an FYI, you can get rid of this:

It’s already using the right database because of the connection that you created above it.

Finally, please don’t leave yourself open to SQL Injection. Rewrite your code to be something more along these lines:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement