Need some more documentation #45
-
I mean don't get me wrong, it's great for what it does cover.
Not knowing how to do this properly, since SQL.INSERT_INTO clearly can't just work out of the box, I went the route of the following, and so question # 2 is something of importance:
Everything else looks great, just wish I had a bit more documentation. Can you confirm that the above is appropriate , or should I just trial and error this software.. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
About executing, you can choose different levels to work at: 1. ADO.NET: You can use CreateCommand(DbConnection, SqlBuilder) or CreateCommand(DbProviderFactory, SqlBuilder) to turn the SqlBuilder into a DbCommand. From that point on, you are responsible for opening the connection and calling ExecuteNonQuery. 2. Database class: The Database class makes things easier. You can call the Execute method like in your example. Database creates a connection when you pass a connection string in the constructor, or you can provide your own DbConnection. Database always uses the same connection, which opens and closes as necessary (you don't need to explicitly open the connection, but you are allowed to). About executing multiple insert statements, calling Execute multiple times works, although there are two things you could do: 1. Use EnsureConnectionOpen, 2. Use TransactionScope. |
Beta Was this translation helpful? Give feedback.
-
I just realized you are creating a batch insert, that's also possible, but you should append a semicolon at the end of each statement. e.g. |
Beta Was this translation helpful? Give feedback.
-
awesome!!! thank you!! I saw the transaction system, and was wondering about that. Looks like the append is the way to go for batching them, that should do the trick. Have to say I am loving the flow, saves so much time. Now i just have to convert a couple hundred standard sql connections over to this system, and life will be good. I appreciate the fast support, and the assistance in thinking this through. I should be on the right track now :) |
Beta Was this translation helpful? Give feedback.
SQL.INSERT_INTO()
is just a shortcut tonew SqlBuilder().INSERT_INTO()
.About executing, you can choose different levels to work at:
1. ADO.NET: You can use CreateCommand(DbConnection, SqlBuilder) or CreateCommand(DbProviderFactory, SqlBuilder) to turn the SqlBuilder into a DbCommand. From that point on, you are responsible for opening the connection and calling ExecuteNonQuery.
2. Database class: The Database class makes things easier. You can call the Execute method like in your example. Database creates a connection when you pass a connection string in the constructor, or you can provide your own DbConnection. Database always uses the same connection, which opens and closes as necessar…