How to convert the code into C#, windows application
-
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then 'If db.Tables.Item(sTableName).Rows > 0 Then db.Tables.Item(sTableName).ExportData(objBCPExport) 'End If Else Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName If Trim(sCondition) <> "" Then sSelectCommand += " WHERE " + sCondition End If 'Create a temporary view to hold data Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) db.Views.Refresh() 'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP) 'Export data to a file db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport) Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try End If
-
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then 'If db.Tables.Item(sTableName).Rows > 0 Then db.Tables.Item(sTableName).ExportData(objBCPExport) 'End If Else Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName If Trim(sCondition) <> "" Then sSelectCommand += " WHERE " + sCondition End If 'Create a temporary view to hold data Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) db.Views.Refresh() 'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP) 'Export data to a file db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport) Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try End If
There are lots of tools for this, but I assume no one is perfect. Do it manually.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void "Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
-
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then 'If db.Tables.Item(sTableName).Rows > 0 Then db.Tables.Item(sTableName).ExportData(objBCPExport) 'End If Else Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName If Trim(sCondition) <> "" Then sSelectCommand += " WHERE " + sCondition End If 'Create a temporary view to hold data Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) db.Views.Refresh() 'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP) 'Export data to a file db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport) Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try End If
First just write in simple english what this code does and then think how to write that in C# I think that's the simplest method
-
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then 'If db.Tables.Item(sTableName).Rows > 0 Then db.Tables.Item(sTableName).ExportData(objBCPExport) 'End If Else Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName If Trim(sCondition) <> "" Then sSelectCommand += " WHERE " + sCondition End If 'Create a temporary view to hold data Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) db.Views.Refresh() 'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP) 'Export data to a file db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport) Try db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default) Catch End Try End If
To Convert to C# from another Language you must Understand C#
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswam@its.co.za