Friday, September 30, 2005

.Net C# howto convert DataReader to Dataset

public DataSet ConvertDataReaderToDataSet(OleDbDataReader reader)
{
DataSet dataSet = new DataSet();
DataTable schemaTable = reader.GetSchemaTable();
DataTable dataTable = new DataTable();

for(int cntr = 0; cntr < schemaTable.Rows.Count; ++cntr )
{
DataRow dataRow = schemaTable.Rows[cntr];
string columnName = dataRow["ColumnName"].ToString();
DataColumn column = new DataColumn(columnName,dataRow.GetType());
dataTable.Columns.Add(column);
}

dataSet.Tables.Add(dataTable);

while (reader.Read())
{
DataRow dataRow = dataTable.NewRow();
for(int cntr = 0; cntr < reader.FieldCount; ++cntr)
{
dataRow[cntr] = reader.GetValue(cntr);
}
}

return dataSet;
}

Wednesday, September 28, 2005

The request failed with HTTP status 401: Unauthorized "System.Net.WebException: The request failed with HTTP status 401: Unauthorized".

The request failed with HTTP status 401: Unauthorized
"System.Net.WebException: The request failed with HTTP
status 401: Unauthorized".

If you use an authentication on your webservice like
Integrated Windows Authentication, you may have
to pre-authenticate before using your webservice:

WebService.webClass myWC= new WebService.webClass();

myWC.PreAuthenticate = true;

myWC.Credentials = System.Net.CredentialCache.DefaultCredentials;

posted on Friday, January 30, 2004 8:37 AM on "Heybo Blog"
http://heybo.com/weblog/posts/245.aspx

Tuesday, September 20, 2005

Convert ArrayList into Array

example:
ArrayList myArray = new ArrayList();
--- somewhere in your code you populate your array
--- then...
int[] myIntArray = (int[])myArray.ToArray(typeof(int));

provided by luiz ( thanks mate )

Thursday, September 15, 2005

Run IE trough batch job...

Dim wshShell
set wshShell = WScript.CreateObject("WScript.Shell")

wshShell.Run "cmd.exe /c ""title StartIE & runas.exe /user:virtual\bsz ""%ProgramFiles%\Internet Explorer\IEXPLORE.EXE"""""

wscript.Sleep(1000)
wshShell.AppActivate "StartIE"
wshShell.SendKeys "I'm2Happy" & "{ENTER}"

Monday, September 12, 2005

Regular Expression Email Check

Function ValidateEmail(Expression)
Dim objRegExp
Set objRegExp = New RegExp
objRegExp.Pattern = "^[\w\.-]+@[\w\.-]+\.[a-zA-Z]+$"
ValidateEmail = objRegExp.Test(Expression)
End Function

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge