Forum Replies Created

ShikhaTan Member

To read transaction log file of SQL server in C# is a hard task. First of all, I’m not aware of a documentation of the file structure. Then the log does not contain SQL statements. It only shows what happened to the database file(s).

For reading the active log and the SQL statements, you may consider using..

-- Read the active log
SELECT	* 
FROM	fn_dblog( null, null );

-- Read from the procedure cache
SELECT	stats.last_execution_time, 
	sqls.[text]
FROM	sys.dm_exec_query_stats stats
	CROSS APPLY sys.dm_exec_sql_text(stats.sql_handle) sqls
ORDER BY stats.last_execution_time;
ShikhaTan Member

Use DataSet to get the XML string.

private void SaveXMLToDatabase()
{

   DataSet dataSet = new DataSet("dataSet");
    DataTable table = dataSet.Tables.Add("Items");
    table.Columns.Add("id", typeof(int));
    table.Columns.Add("Item", typeof(string));

    // Add ten rows.
    DataRow row;
    for(int i = 0; i <10;i++)
    {
        row = table.NewRow();
        row["id"]= i;
        row["Item"]= "Item" + i;
        table.Rows.Add(row);
    }

     string xmlString = dataSet.GetXml();
// INSERT TO SQL DATABASE

}
ShikhaTan Member

You might be looking for Delegates…but we’d need more details about how you’d actually do this to be sure:

https://msdn.microsoft.com/en-us/library/ms173171.aspx
ShikhaTan Member
MyFunc(1, 2, "hello")
AnotherFunc(25.3, "have a good day", "here's another string", 22)
void Myfunc(int one,int two,string hello){
//todo: do something here
}
AnotherFunc(double dblone,string strGreeting,string strAnother, int param4)
{
//todo: do something here
}

Can I pass this function off to a function that takes arbitrary functions that will get called later when some event occurs? You would have to have the variables set as global otherwise they would be out of scope. Global variables are highly frowned upon by the code

ShikhaTan Member

yeah i know what void is, i just use it whenever i make my own function, like I’ve never seen it used for main() , that confused me heaps.. nah i prefer to use using namespace std; .. it just confuses me otherwise

ShikhaTan Member

all those functions you wrote already exist in the stl….learn the stl if you want to call yourself a c++ programmer. No point in reinventing the wheel, and all stl containers and algorithms by standard enforce certain run times (which are generally fast) and can even be faster (ie. sorts in stl are usually O(n logn) complexity, while above example is O(n^2))

Viewing 6 posts - 106 through 111 (of 111 total)
en_USEnglish