|
Assuming you're missing counters specific to .NET, does running lodctr %WINDIR%\Microsoft.NET\Framework\v1.0.3705\CORPerfMonSymbols.ini at the command prompt help?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
No these were Windows performance counters (not specific to .NET) The CORPerfMonSymbols are all there.
Anyways, thanks man.
Salil Khedkar [^]
|
|
|
|
|
Hi,
I am developing the Date Access Tier. Can soem one help me with a stand alone SqlDataReader. I have created a connection class and would like to then open the connection in the Data Access class, but I am stuck. Every piece of material that I read, just implements code in the same class. I Know that i can drag and drop the connection and all but i don't want to do that. I am new to coding.
<code>
public class Connectivity
{
private string ServerName = "";
//private string prvWINNTAuth = "";
//private string sDBInfo = "";
//private string sStaticDataConnectionString = "";
private string DatabaseName = "";
public Connectivity()
{
DatabaseName = "(Local)";
ServerName = "DataBase";
}
public SqlConnection SetConnection()
{
return GetConnection();
}
private string UserName
{
get{return prvUserName;}
set{prvUserName = value;}
}
private string Password
{
get{return prvPassword;}
set{prvPassword = value;}
}
private string DatabaseName
{
get{return prvDatabaseName;}
set{prvDatabaseName = value;}
}
private string ServerName
{
get{return sServerName;}
set{sServerName = value;}
}
<code>
private int WinNTAuth
{
get{return bUseWinSecurity;}
set{bUseWinSecurity = value;}
}
private int UserAccessLevel
{
get{return iAccessLevel;}
set{iAccessLevel = value;}
}
private string ConnectionString()
{
string connStr = "";
string sMsg = "";
try
{
connStr = "server=" + ServerName + ";" +
"integrated security=SSPI;" +
"database=" + DatabaseName;
}
catch (Exception ex)
{
connStr = "";
sMsg = "DataAccess: ConnectionString: " + ex.Message.ToString();
throw new Exception(sMsg);
}
try
{
if (WinNTAuth == Convert.ToInt16(vbWINNTAuth.vbUseApplication))
{
connStr = connStr + "user id=" + UserName + ";";
connStr = connStr + "PWD=" + Password + ";";
}
else
{
connStr = connStr + "persist security info=True;";
connStr = connStr + "integrated security=sspi;";
}
}
catch (Exception ex)
{
connStr = "";
sMsg = "DataAccess: ConnectionString: " + ex.Message.ToString();
throw new Exception(sMsg);
}
return connStr;
}</code>
private SqlConnection GetConnection()
{
<code>string sMsg = "";
SqlConnection conn = new SqlConnection(ConnectionString());
try</code>
{
conn.Open();
return conn;
}
catch (Exception ex)
{
conn.Close();
if(conn != null)
{
conn = null;
}
sMsg = "DataAccess: GetConnection: " + ex.Message.ToString();
throw new Exception(sMsg);
}
}
public void CloseConnection(SqlConnection conn)
{
string sMsg = "";
try
{
if (conn.State != ConnectionState.Open)
{
conn.Close();
if(conn != null)
{
conn = null;
}
}
}
catch (Exception ex)
{
sMsg = "DataAccess: Login: " + ex.Message.ToString();
throw new Exception(sMsg);
}
}
public bool Login()
{
string sMsg = "";
bool ret = true;
SqlConnection cn = new SqlConnection(ConnectionString());
try
{
cn.Open();
if (cn.State != ConnectionState.Closed)
{
ret = true;
cn.Close();
}
else
{
ret = Convert.ToBoolean(ConnectionState.Closed);
}
}
catch (Exception ex)
{
if (cn.State != ConnectionState.Closed)
{
cn.Close();
if(cn != null)
{
cn = null;
}
}
sMsg = "DataAccess: Login: " + ex.Message.ToString();
throw new Exception(sMsg);
}
return ret;
}
<code></code><code></code></code></code>
|
|
|
|
|
just do a command object and return if
SqlCommand cmd = new SqlCommand( "<stroed procedure name>", conn);
cmd.CommandType = CommandType.StoredProcedure;
return cmd.ExecuteDataReader();
while to read:
while( myReader.Read() )
{}
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Thanks Ista.
|
|
|
|
|
You can use Relection to populate the class also
Get the name of the field. Get the Name of the Property into a PropertyInfo object then call set value.
Then you wont have and hunky stored proc code for getting and saving.
Use CommandBuilder.DeriveParameters to get all the parameters dynamically
use the reader to step through
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote: You can use Relection to populate the class also
Get the name of the field. Get the Name of the Property into a PropertyInfo object then call set value.
Then you wont have and hunky stored proc code for getting and saving.
Use CommandBuilder.DeriveParameters to get all the parameters dynamically
use the reader to step through
I will try it tonight as I am still working on my project and will start in about five minutes. I will let you know if i have any other questions. thanks for the all your help
|
|
|
|
|
Hello
I am trying to use principal permission in my code, using the imperative security permission, as follow.
appAdmin.CurrentDomain.SetPrincipalPermissionPolicy(PrincipalPolicy.WindowsPrincipal);
void doMe()
{
PrincipalPermission iPerm = new PrincipalPermission(null,"RoleName");
iPerm.Demand();
}
And then I created a new role ("RoleName") and assign it to my user, using the azman console.
But when I am trying to run this code, I get the exception: "request for principal permission failed".
|
|
|
|
|
how to configure log4net for class library project
|
|
|
|
|
|
Thanks for the reply. But the solution given in the website is for Winform or console but the same code didnt work for class library do you have anything for the class library.
|
|
|
|
|
How can I use CrystalReport in WebApplication.
|
|
|
|
|
Why don't u google[^] it?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
my application host server has a virtual memory and physical memory limit set (150mb for virtual, 100mb for physical) in iis application pool, now my application keeps getting recycled. event viewer says "process x from application pool y has reached its virtual memory limit."
how do i get around this?, ive used performance monitor to monitor my application, it doesnt seem to leak any memory.
any ideas?
|
|
|
|
|
I have a string, oldWord, that contains exactly 1 space SOMEWHERE in it. I want to generate 26 copies of that word with the space being converted to a letter, 'a' through 'z'.
I tried this:
string oldWord;
string[] newWord;
...
for (int c = 0; c < 26; c++)
{
newWord[c] = oldWord.Replace(' ', 'a'+c );
}
The compiler complains about the parameter, 'a'+c , as being an "invalid char", as you probably expected. I've tried lots of different combinations, to no avail. Would you please tell me how i can code that parameter so i get the expected result?
Thank you.
|
|
|
|
|
Hi!
Do it like this:
newWord[c] = oldWord.Replace(' ', (Char)((int)'a'+c));
It converts the 'a' to a value, add the additional value and convert it back to a character.
Marcel Erz
|
|
|
|
|
Hi,
You can also try this ...
<br />
string oldWord = "Hello Welcome";<br />
string newWord = "";<br />
for (int c = 0; c < 26; c++)<br />
{<br />
int newchar = (int)'a'+c;<br />
newWord += oldWord.Replace(' ', (char)newchar );<br />
}<br />
System.Diagnostics.Debug.WriteLine(newWord);<br />
Result:
<br />
"HelloaWelcomeHellobWelcomeHellocWelcomeHellodWelcomeHelloeWelcomeHellofWelcomeHellogWelcomeHellohWelcomeHelloiWelcomeHellojWelcomeHellokWelcomeHellolWelcomeHellomWelcomeHellonWelcomeHellooWelcomeHellopWelcomeHelloqWelcomeHellorWelcomeHellosWelcomeHellotWelcomeHellouWelcomeHellovWelcomeHellowWelcomeHelloxWelcomeHelloyWelcomeHellozWelcome"<br />
Happy Programming!!!
Regards,
P.Anbuselvan
Sr.Software Engineer
Hyderabad
|
|
|
|
|
Here is another suggestion: Why not use a character counter:
int i = 0;
for (char c = 'a'; c <= 'z'; c++) newWord[i++] = oldWord.Replace(' ', c);
---
b { font-weight: normal; }
|
|
|
|
|
Thank you ALL for the excellent suggestions. I tried the 1st 2 suggestions before the 3rd was made ... they both worked great ... PLUS i got the added benefit of learning how to 'cast'.
Thanks again,
|
|
|
|
|
Hi All
I need to find the date of the day before today and create string of this date.
I cant find the date of today and make less 1 from the date because i could get 0 in date (if i try to find the yesterday of 1.1.2005 i need to get 31.12.2004 ).
I sure that there is some build in method to do it -
Some one can help me ?
Thanks.
|
|
|
|
|
DateTime.Now.AddDays(-1);
|
|
|
|
|
Hi!
Just use the methode AddDays from the DateTime-class and give as parameter a negative value.
DateTime loDate = new DateTime();
loDate = DateTime.Now;
loDate = loDate.AddDays(-1);
MessageBox.Show(loDate.ToString());
other samples:
loDate = loDate.AddDays(-5); // Subtract 5 days
loDate = loDate.AddMonths(-3); // Subtract 3 months
Marcel Erz
|
|
|
|
|
Try using
DateTime dt = DateTime.Now ;
dt = dt.Subtract(new TimeSpan(1,0,0,0,0)) ;
Console.WriteLine(dt.ToShortDateString()) ;
Hope this helps.
Bikash Rai
|
|
|
|
|
What is the difference between Singleton implemented using static GetInstance() method and having a Class with all Public Static methods. Is scenario#2 a Singleton class? Please let me know the differences between these two approaches.
1)-----------------
public class SealedClass
{
private static SealedClass _class = new SealedClass();
private SealedClass()
{}
public static SealedClass GetInstance
{
get
{
return _class;
}
}
}
--------------------------------------
2) public class StaticClass
{
public static string GetName()
{
return "Shubho";
}
public static string GetAddress()
{
return "Shubho";
}
}
|
|
|
|
|
Interesting question.
According to the GoF, the purpose of a singleton is to "ensure a class has only one instance, and provide a global point of access to it." Your second example has no instance, its just a collection of static methods and hence we couldn't get a reference to it.
Microsoft has a best practice with regard to singletons - they say it should be implemented as follows - a thread safe lazy implementation
public class Singleton
{
private Singleton() {}
private static volatile Singleton _singleton;
private static object _lock = new object();
public static Singleton Value
{
get
{
if (_singleton == null)
{
lock(_lock);
{
if (_singleton == null) _singleton = new Singleton();
}
}
return _singleton;
}
}
}
Regards,
Rob Philpott.
|
|
|
|