Posted by malakablog on March 31, 2009
I have IDictionary Object called ListOptions. To use it as the data source for an ASP.NET DropDownList called objDropDownList:
objDropDownList.DataSource = ListOptions;
objDropDownList.DataTextField = “Value”;
objDropDownList.DataValueField = “Key”;
objDropDownList.DataBind();
Posted in Uncategorized | Tagged: application, beginner, C#, code, Collection, Datatabe, development, Dictionary, dropdown, DropDownList, IDictionary, JavaScript, list, Programming, VS2005 | Leave a Comment »
Posted by malakablog on February 18, 2009
I have a collection object (EmployeesCollection) for custom Employee class, In the Employee class there are two properties Name and EmployeeID. I want to sort the EmployeesCollection by Name and use it in a DropDown List (ddEmployees).
DataTable dtEmployees = new DataTable();
dtEmployees.Columns.Add(“Name”);
dtEmployees.Columns.Add(“EmployeeID”);
foreach (Employee vEmployee in EmployeesCollection)
{
dtEmployees.Rows.Add(new object[] { vEmployee.Name, vEmployee. EmployeeID });
}
dtEmployees.DefaultView.Sort = “Name”;
ddEmployees.DataSource = dtEmployees;
ddEmployees.DataTextField = “Name”;
ddEmployees.DataValueField = “EmployeeID”;
ddEmployees.DataBind();
Posted in Uncategorized | Tagged: application, beginner, C#, code, Collection, Datatabe, development, dropdown, JavaScript, list, Programming, sort, VS2005 | Leave a Comment »
Posted by malakablog on October 10, 2008
So I have a View that join different tables, I wanted to get the Table name of a Field in the View. So I created a Function [GetTableName] with the following Inputs
- View Name
- Connection String of the View.
- The required Field Name
This is the function
public string GetTableName (string ViewName, string ConnString, string FieldName)
{
SqlConnection MyConnection;
string toReturn = ViewName;
MyConnection = new SqlConnection(ConnString);
MyConnection.Open();
DataTable MyTable = MyConnection.GetSchema(“Views”);
foreach (DataRow dRow in MyTable.Rows)
{
object[] sqlArray = dRow.ItemArray;
if (sqlArray.GetValue(2).ToString() == ViewName)
{
DataTable MyVTable = MyConnection.GetSchema(“ViewColumns”);
foreach (DataRow dVRow in MyVTable.Rows)
{
object[] sqlVArray = dVRow.ItemArray;
if (sqlVArray.GetValue(2).ToString() == ViewName)
{
if (sqlVArray.GetValue(6).ToString() == FieldName)
{
toReturn = sqlVArray[5].ToString();
}
}
}
}
}
return toReturn;
}
Posted in Uncategorized | Tagged: application, beginner, C#, code, Connection, Database, development, Field, Function, SQL 2000, Table, View, VS2005, Web.Services, WebMethods | Leave a Comment »
Posted by malakablog on September 17, 2008
I was working on a Console application that read SQL Database connection details from a configuration file then send these details to another application (Let us call it the Update Application) which will go through the records of a table to update them using a For Loop, I wanted to show a status message on the Console screen for each record.
In the Update Application (VB.NET) I defined a Public event to handle the status message
Public Event Message(ByVal sMessage As String)
In the update function I raised this event with the required message
For Each dbRow In DataSet.Tables(“DataTables”).Rows
RaiseEvent Message(“Start Processing record of ID “ & dbRow (“ID”).ToString())
‘Do the Update Here
RaiseEvent Message(“End Processing record of ID “ & dbRow (“ID”).ToString())
Next
In the Console Application (C#) I defined a handler for the event
using System;
using System.IO;
public delegate void UpdateAppMessageHandler(string myString);
I defined the required function for the event handler
internal class Program
{
UpdateAppMessageHandler MySEvent = new UpdateAppMessageHandler (ConsolAppMessageHandler);
static void ConsolAppMessageHandler(string sMessage)
{
Console.WriteLine(sMessage);
}
Now I need to assign the Update Application event to the event handler in the Console Application
private static void Main(string[] args)
{
try
{
UpdateApp MyUpdateApp = null;
MyUpdateApp = new UpdateApp ();
MyUpdateApp.Message += ConsolAppMessageHandler;
.
.
.
Now the Console Screen will show a message for Start/End processing of each record in the Database
Posted in Uncategorized | Tagged: application, beginner, C#, code, Console, DB, development, Event handler, HTML, JavaScript, message, Programming, VB.NET | Leave a Comment »
Posted by malakablog on July 31, 2008
I lost some of my applications code coz of PC format, one of these applications is a C# Console Application, I managed to get the exe output of this application but I was not able to retrieve the code files so I used (.NET Reflector) to do this:
1- Download the .NET Reflector.
2- Download the Reflector.FileDisassembler.
3- Extract the .Net Reflector
4- Extract the Reflecter.FileDisaembler
5- Copy the Reflector.FileDisassembler.dll to the .Net Relector Folder
6- Start Relector.EXE
7- From the View menu select Add-Ins

8- In the Add-Ins Screen select Add and select Reflector.FileDisassembler.dll then close the Add-Ins screen

9- From File menu select Open and select the exe file you want to retrieve its code

10- The reflector will load the file Assembly in the Assemblies section

11- Select the required file and from the Tools menu select File Disassembler

null
12- Click Generate and you will get your code

null
Finally I would like to thank Siderite for his help
Posted in Uncategorized | Tagged: .Net, .NET Reflector, Assembly, C#, development, recovery, Reflector.FileDisassembler | 9 Comments »