如果无法访问服务器,如何保存SQL Update以供日后使用

时间:2014-12-06 21:31:54

标签: sql-server vb.net ado.net

目前,我正在使用SQLAdapter Update命令更新从DataTable到SQL数据库的更改。如果服务器不可用,我想知道如何缓存更改以供日后使用。有没有办法从Update命令中提取SQL并稍后在数据库上执行它们?

sqlConn = New SqlConnection(AppConnection)
sqlConn.Open()
sqlAdapter = New SqlDataAdapter
sqlAdapter.SelectCommand = New SqlCommand
sqlAdapter.SelectCommand.Connection = sqlConn
sqlAdapter.SelectCommand.CommandText = "SELECT * FROM SampleTable"

Dim objSQLBuilder As SqlCommandBuilder = New SqlCommandBuilder(sqlAdapter)

'THIS IS NOT RETURNING THE COMPLETE SQL STATEMENT
sqlAdapter.UpdateCommand = objSQLBuilder.GetUpdateCommand()   

'IF THIS FAILS, I WANT TO CACHE THE SQL AND EXECUTE THE SQL LATER...
sqlAdapter.Update(dtDataTable)   

感谢您的帮助!

0 个答案:

没有答案