|
ok guyz thx for the answer I found on google what I was looking for.. before that I couldnt find because I spelt it incorrect ;] thx for help anyway
|
|
|
|
|
<br />
string str = "000CB8B8"; <br />
<br />
char[] ch=str.ToCharArray();<br />
<br />
string strev = "";<br />
for (int i = (ch.Length-1); i >= 0; i--)<br />
{<br />
strev += ch[i].ToString();<br />
}<br />
reversed string will be on strev<br />
|
|
|
|
|
Reversing the nibbles won't correctly change the endianess of the number. You have to reverse the bytes:
string number = "000CB8B8";
string swapped = string.Empty;
for (int i = number.Length - 2; i >= 0; i -= 2) {
swapped += number.Substring(i, 2);
}
---
b { font-weight: normal; }
|
|
|
|
|
I am looking for suggestions/pros/cons of using typed datasets vs. custom classes for my DAL/BLL.
Anyone have any thoughts on eXpress Persistance Objects from DevExpress or dOOdads from MyGeneration software?
Any other solutions?
|
|
|
|
|
Use both! Make the typed Datasets the DAL and some classes the BLL. Your presentation layer then makes calls to the BLL wich in turn makes a call to the typed datasets.
If you use the System.ComponentModel.DataObject and System.ComponentModel.DataObjectMethodAttribute attributes in your BLL then you can even use your classes as datasources for gridviews et al.
I do it this way because the database people make me do things I don't like to do, like a switch in the database has to be a char(1) with 'Y' or 'N' in it instead of a bit field, so I use the BLL to abstract it so I can just use bools in my code.
private char isActive;
public bool IsActive
{
get { return this.isActive == 'Y' ? true : false; }
set { this.isActive = value ? 'Y' : 'N'; }
}
|
|
|
|
|
I am looking to create an Data Access Layer and Business Logic Layer for a new web site. I am looking for suggestions on the best practice on how to handle the database connection from the DAL.
I have seen examples where every function in the DAL creates a connection, runs the query, and then closes the connection based on the connection string passed into the DAL. With connection pooling this doesnt seem to be a big issue. Is this the best method for a web application since it is stateless? Or, is it better for the BLL to create a connection and pass the connection into the DAL? How is the best way to get the connection string from the Web.config file to the DAL? Does the BLL pass the connection string into the DAL or is there a better way?
I am looking at using ASP 2.0 but I didnt want to use the table adapter wizard.
Any examples would be greatly appreciated.
|
|
|
|
|
All I can say is what I do... I keep ALL connection/database/sql out of the BLL. This way if my application moves to a different database all I have to do is rewrite the DAL and the rest of your application works fine. I also only use the presentation layer to do presentation; the BLL is what messes with the data.
|
|
|
|
|
Do you have each function in the DAL also handle the connection?
How do you recommend the best way to have the DAL get the connection string?
|
|
|
|
|
Recently I've been using typed datasets, I think they open a connection each time. In my older projects I did open a connection for each request. However, my apps are internal workflow applications though, so they are not serving 100,000 hits /sec or anything :p
I put the connection string in app.config.
|
|
|
|
|
Hi All,
How can I assign a Text control's Text value to a numeric datatype.
If I do like this
double temp = Text1.Text gives compile time error.
In case if I cast as follows
double temp=(double) Text1.Text gives run time error as
invalid cast.
Some body had suggested me to use TryParse() ot Parse method of numeric data type.
But I do see any method for numeric data type namely TryParse() or Parse().
I have .NET Framework 1.1 and VS 2003.
Regards,
Amol
Every thing will come to you if you have faith.
|
|
|
|
|
In Framework 1.1 there's no TryParse but a Parse method.
double temp = Double.Parse(Text1.Text);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
try
Convert.ToDouble(str); method
|
|
|
|
|
|
Hi folks,
I've create a UserControl that could return a property of type
AddressCollection - a collection of Address classes (derived from
CollectionBase). I've also created an AddressTypeConverter that's being
derived from TypeConverter as well as an AddressCollectionEditor that's
being derived from CollectionEditor as follows:
public class AddressCollectionEditor : CollectionEditor<br />
{<br />
public AddressCollectionEditor(Type type)<br />
: base(type){}<br />
<br />
protected override bool CanSelectMultipleInstances(){return<br />
false;}<br />
<br />
protected override Type CreateCollectionItemType(){return<br />
typeof(Address);}<br />
}<br />
<br />
[Serializable]<br />
public class AddressTypeConverter : TypeConverter<br />
{<br />
public override bool CanConvertTo(ITypeDescriptorContext<br />
context, Type destinationType)<br />
{<br />
if (destinationType == typeof(InstanceDescriptor))<br />
return true;<br />
<br />
return base.CanConvertTo(context, destinationType);<br />
}<br />
<br />
public override object ConvertTo(ITypeDescriptorContext<br />
context, System.Globalization.CultureInfo culture, object value, Type<br />
destinationType)<br />
{<br />
if (destinationType == typeof(InstanceDescriptor))<br />
{<br />
Address addr = value as Address;<br />
if (addr == null)<br />
return new<br />
InstanceDescriptor(typeof(Address).GetConstructor(System.Type.EmptyTypes),<br />
null);<br />
<br />
return new<br />
InstanceDescriptor(typeof(Address).GetConstructor(new Type[] {<br />
typeof(string), typeof(string), typeof(string), typeof(string),<br />
typeof(string), typeof(string), typeof(string) }),<br />
<br />
new string[] { addr.Type, addr.Street1, addr.Street2, addr.City,<br />
addr.StateProvince, addr.ZipPostalCode, addr.CountryRegion });<br />
}<br />
<br />
return base.ConvertTo(context, culture, value,<br />
destinationType);<br />
}<br />
}<br />
<br />
public partial class AddressCtrl : UserControl<br />
{<br />
<br />
[Category("Misc"), Description("Get a collection of<br />
addresses.")]<br />
[Editor(typeof(AddressCollectionEditor), typeof(UITypeEditor))]<br />
<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]<br />
public AddressCollection Addresses<br />
{<br />
get { return m_coll; }<br />
}<br />
<br />
}<br />
<br />
[Serializable]<br />
[TypeConverter(typeof(AddressTypeConverter))]<br />
public class Address : ICloneable<br />
{<br />
<br />
private string m_strType;<br />
private string m_strStreet1, m_strStreet2;<br />
private string m_strCity, m_strStateProvince;<br />
private string m_strZipPostalCode, m_strCountryRegion;<br />
<br />
public Address()<br />
: this("Unknown", string.Empty, string.Empty, string.Empty,<br />
string.Empty, string.Empty, string.Empty)<br />
{<br />
}<br />
<br />
public Address(string strType, string strStreet1, string<br />
strStreet2, string strCity, string strStateProvince, string<br />
strZipPostalCode, string strCountryRegion)<br />
{<br />
}<br />
<br />
through some<br />
}
Everything works fine and the following code is generated in the
InitializeComponent:
<br />
this.addressCtrl1.Addresses.AddRange(new Address[] {<br />
new Address("Business", "", "", "", "", "", ""),<br />
new Address("Home", "", "", "", "", "", ""),<br />
new Address("Shipping", "", "", "", "", "", ""),<br />
new Address("Billing", "", "", "", "", "", "")});<br />
However, when I try to remove a given item, the InitializeComponent
looks like this:
<br />
this.addressCtrl1.Addresses.AddRange(new Address[] {<br />
((Address)(new Address())),<br />
((Address)(new Address())),<br />
((Address)(new Address())),<br />
((Address)(new Address()))});<br />
Would you please let me know what I'm doing wrong?
Thank you for your time,
Mehdi
|
|
|
|
|
hi,
have anybody a link or something for creating a code that do a screenshot on click?!
|
|
|
|
|
There are several articles on this site the demonstrate how to do precisely that.
|
|
|
|
|
Where? I Had search but nothing found
|
|
|
|
|
|
How do I create an eyedroppper tool that is similar to adobe or maybe paint???
|
|
|
|
|
1) Find an icon for an eye dropper
2) Override the MouseMove event on a control
3) Map the point to the control coordinates
4) Override the OnPaint event and pass the base class a fake graphics context to draw one
5) Read the pixel at the point
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
hai all,
i have extracted the unicode and arabic characters from thousands of file and stored in a common file.
but, the characters get repeated in the common file.
how to remove the duplicate character...
----string str=(streamreader) sdr.readtoend();-------
char[] array = str.ToCharArray();
for(int i=0;i<array.length;i++)
{
int="" uc="(int)array[i];
if(uc">= 1536 && uc <=1791)
sw.WriteLine(uc.ToString()+"\t"+ new string(array,i,1));
}
Vp
-- modified at 10:38 Wednesday 2nd August, 2006
|
|
|
|
|
Use a stream to loop through the characters a large portion at a time ( not read to end as it takes too much memory) Create a large array of booleans set to false. While looping through the file check to see if it exists and if not write it to another stream.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
(UPDATED)
Hi all,
I have a problem I can't seem to resolve. Im not 100% certain the C# forums are the right place to post this, sorry if that is the case. It's kind of a crossover problem.
I would be really grateful with any tips how to resolve my strange problem.
Problem context:
OS: Windows 2000 Server - IIS 6.0 - .NET framework 1.1
I wish to call a Web Service from an ASP page (VBScript). The Web Service is Document/Literal based (WSDL generated by JBoss App Server) so the good old MS SOAP Client 3.0 doesn't cut it. My solution: Create a c#/.NET DLL accessing the Web Service, make it COM interoperable and let the ASP call it using standard Server.CreateObject.
Well - everything works. Or worked. I created the C# class and followed a guide how to make the COM interoperability work. If I call the DLL from a stand-alone VB6 app or a C# console application, everything works as a charm - the web service is invoked and everyone is happy.
Problem: When I call it from the ASP script, I get a:
Microsoft VBScript runtime error '800a01ae'
Class doesn't support Automation: 'stub.updateContact'
The most strange is that it actually worked for perhaps 5 or 6 times. Then I got intermittent error messages about the Automation thing, but after that I get the same one every time.
I've cleaned the registry, recompiled the DLL numberous times, rebooted the server, triple checked the WSDL. Nothing helps. And - it always work when I access the "updateContact" function from a stand-alone VB6 or C# application.
It seems as the IIS is spooked.
I've debugged the whole thing so far I know the updateContact method will execute successfully if I out-comment all WSDL-proxy class related lines of code and simply let the method return a string. However - any instanciation of the proxy classes will trigger this error. The error does not seem to be "catchable" using try{..}catch(){..} clauses either.
I've googled a whole lot before posting this without any success.
Thanks for any help.
UPDATE:
It seems as I managed to solve the problem. By accident I suddenly got a command through when testing some other indata to the C# function. The data is actually a number of parameters, retrieved from a database. The ASP page asks for the ID of the table row, retrives the ResultSet and so on. Well - somehow the C# goes nuts when one or more of the indata parameters were NULL in the database. If I corrected the null ones in the DB, it works.
The test apps I used just sent static (non-null) data into the function which explains why it worked for those all the time.
-- modified at 10:46 Thursday 3rd August, 2006
|
|
|
|
|
My code:
object o = null;
object zoom = (object)50; // %
WebBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref o, ref zoom);
But this code don't work. Help me please.
|
|
|
|
|
Hi,
I have two generic Lists of data and I want to compare the values.
Fill the mappinglist we want to compare the sourcelist with
<br />
List<MappingItem> MappingList = new List<MappingItem>();<br />
MappingList.Add(new MappingItem("11", "1"));<br />
MappingList.Add(new MappingItem("22", "2"));<br />
MappingList.Add(new MappingItem("44", "4"));<br />
MappingList.Add(new MappingItem("55", "5"));<br />
Fill the Sourcelist we want to deal with
<br />
List<SourceItem> SourceList = new List<SourceItem>();<br />
SourceList.Add(new SourceItem("11", "Value one"));<br />
SourceList.Add(new SourceItem("22", "Value two"));<br />
SourceList.Add(new SourceItem("33", "Value three"));<br />
SourceList.Add(new SourceItem("44", "Value four"));<br />
SourceList.Add(new SourceItem("55", "Value five"));<br />
Make a instance of the DestinationList and the Itemobject
<br />
List<DestinationItem> DestinationList = new List<DestinationItem>(); <br />
DestinationItem destItem;<br />
Here is the problem Im stuck with. How shall I compare the values between these lists in a high performance way och with nice methods?
This is a uncomplete way, maybe u have a better method but I hope you understand what Im looking for!?!
<br />
<br />
foreach (MappingItem mappItem in MappingList.FindAll(new Predicate<MappingItem>(???)))<br />
{<br />
destItem = new DestinationItem(mappItem.DestId,"?SourceItem.Value?");<br />
DestinationList.Add(destItem);<br />
}<br />
<br />
Write the output
<br />
DestinationList.ForEach(delegate(DestinationItem d)<br />
{ Console.WriteLine("DestId: {0}, Value: {1}", d.DestId, d.Value); });<br />
Output result:
DestId: 1, DestValue: value one
DestId: 2, DestValue: value two
DestId: 4, DestValue: value four
DestId: 5, DestValue: value five
I hope I make my self clear
//Albin
|
|
|
|
|