It's actually inline SQL:
sb.Append("INSERT INTO AgentRole (AgentID, RoleID) ")
sb.Append("VALUES(")
sb.Append(AgentID.ToString
sb.Append(", ")
sb.Append(RoleID.ToString)
sb.Append(")")
Hello,
I have a piece of code that writes to three different tables in three databases. Everything works except the attempt to write records to the second table on the first database. It was working before, but now I can't put records in it.
I have checked, and the correct connection string is indeed pointing to the right database at the right time. Is it possible that there is some sort of lock on the table in question and that I'm not being informed of it when the program runs?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
What I'm trying to find out with the return value (if you use ExecuteNonQuery, as recommended) is if the database is saying it performed the insert. The return value of ExecuteScalar would be irrelevant, as this query doesn't get a value back.
The next thing to try would be to run the query in SQL Server Management Studio and see if it works.
How do you know it isn't working? Are you comparing the number of rows in the table before and after or looking for the values that were supposed to be inserted?
I would also look at the table structure. Is either of these fields an Identity column? Is there a trigger defined on this table that might be altering or deleting data?
Business Accounts
Answer for Membership
by: WesWilsonPosted on 2009-10-21 at 06:37:30ID: 25623749
Please provide the Stored Procedure that is failing (if it is a Stored Procedure) and the code that writes to these databases.