问题描述
如何得到sqlcommandbuilder﹐sqldataadpter自動產生的updatecommand,deletecommand,insertcommand的完整sql語句。
解决方案
解决方案二:
up
解决方案三:
SqlConnectionconnection=newSqlConnection(connectionString);SqlDataAdapteradapter=newSqlDataAdapter();adapter.SelectCommand=newSqlCommand(queryString,connection);SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);//得到对应的SQL语句stringdeleteSql=builder.GetDeleteCommand().CommandText;stringinsertSql=builder.GetInsertCommand().CommandText;stringupdateSql=builder.GetUpdateCommand().CommandText;
解决方案四:
引用2楼zhoufoxcn的回复:
C#codeSqlConnectionconnection=newSqlConnection(connectionString);SqlDataAdapteradapter=newSqlDataAdapter();adapter.SelectCommand=newSqlCommand(queryString,connection);SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);//得到对应的SQL语句stringdeleteSql=builder.GetDeleteCommand().CommandText;stringinsertSql=builder.GetInsert…
解决方案五:
引用2楼zhoufoxcn的回复:
C#codeSqlConnectionconnection=newSqlConnection(connectionString);SqlDataAdapteradapter=newSqlDataAdapter();adapter.SelectCommand=newSqlCommand(queryString,connection);SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);//得到对应的SQL语句stringdeleteSql=builder.GetDeleteCommand().CommandText;stringinsertSql=builder.GetInsert…
解决方案六:
謝謝各位我先試試
解决方案七:
要在修改過數據動作后才能用下面的吧。stringdeleteSql=builder.GetDeleteCommand().CommandText;stringinsertSql=builder.GetInsertCommand().CommandText;stringupdateSql=builder.GetUpdateCommand().CommandText;可是我是這樣寫﹐但updatesql是空的呢
解决方案八:
引用2楼zhoufoxcn的回复:
C#codeSqlConnectionconnection=newSqlConnection(connectionString);SqlDataAdapteradapter=newSqlDataAdapter();adapter.SelectCommand=newSqlCommand(queryString,connection);SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);//得到对应的SQL语句stringdeleteSql=builder.GetDeleteCommand().CommandText;stringinsertSql=builder.GetInsert…