|
Could you please explain what you mean by this - "Use .NET 2.0 with generics". What generics are you talking about?
|
|
|
|
|
Instead of defining a struct you should define a class.
public class MySpecialData
{
private bool isDataDirty;
public bool IsDataDirty { get{ return isDataDirty; } }
private string someValue;
public string SomeValue
{
get { return someValue; }
set { someValue = value; }
}
public int GetHashcode(){}
}
Now it was a known issue that collections of data (even strong typed collections) bring in boxing and downcasting/upcasting issues. Visual Studio 2005 and the 2.0 .NET Framework solve that by using what is called Generics. This moves your collection definition from runtime to compile time. As such your collection is now fully strong typed and no boxing occurs.
public class MySpecialDataCollection : Dictionary< int, MySpecialData> {}
The statement above uses generics....and that is all you need define for a fully functional collection. When you compile your program, the dictionary expects a key of type int and data of type MySpecialData. So at execute time, you do not have any boxing or downcasting occuring at all!!!
Then to use it, it is as any other dictionary:
MySpecialDataCollection list = new MySpecialDataCollection();
foreach (Twizzle element in MyTwizzleCollection )
{
list.Add( element.SpecialObject.GetHashcode(), element.SpecialObject);
}
|
|
|
|
|
I've created an application using VS2005 Express using SQLServer 2005 express. Now the fun bit. How do I create an installation program that installs the SQLServer Express runtime, my application SQLServer express database on a server and update my client connection strings to the database???
Regards,
|
|
|
|
|
Hello,
what i have is this
foreach( FileInfo f in di.GetFiles("*.txt"))
{
//do something
}
foreach( FileInfo f in di.GetFiles("*.log"))
{
//do the same thing
}
what i wan't is this
foreach( FileInfo f in di.GetFiles("*.txt, *.log"))
{
//do something
}
but di.GetFiles("*.txt, *.log") returns nothing.
can i put in a RegEx or something?
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Nope, you're pretty limited in this regard. Maybe an alternative is to pair up the collections:
List<FileInfo> lst = new List<FileInfo>();
lst.AddRange(di.GetFiles("*.txt"));
lst.AddRange(di.GetFiles("*.log"));
foreach (FileInfo fi in lst) { ... }</FileInfo></FileInfo>
If you want them to be in a particular order, then you can just call Sort() .
Logifusion[^]
|
|
|
|
|
Setteled on this
foreach( string f in Directory.GetFiles(_ControleFileBucket))
{
if( f.EndsWith("*." + CDoc.EmailCF) || f.EndsWith("*." + CDoc.FaxCF)||f.EndsWith("*." + CDoc.GMailCF))
{ ...
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Hello,
I am trying to do logging to SQL Server 2000 database by using Database Trace Listener. The problem I have is very strange:
Scenario1:
I have SQLExpress installed on my machine and I was able to achive logging in database in this scenario where I was using integrated security I I got all the desired value in tables; such as Log, Category etc.
Scenario2:
I furtured my experiment by doing logging on SQL Server 2000 which is installed on a seperate machine but within the domain where my machine is registered as well. After I got done creating tables and stored procedure in already made database. When ever I tried to do logging in the database nothing happens, no data get populated in Data tables such as Category, Log etc. I tried using integrated security after impersonating my application to an administrator accout, I tried by making connection string by using "sa" account. Nothing is working..
Can somebody give me any clue?
Thanks in advance
|
|
|
|
|
Hi
My app has a Wizard like interface that has 4 pages.
I have created a phone class in this app. On the second page, depending on user's selection I have to instantiate either a digital phone class or normal phone class(Both inherite from parent phone class)
I instantiate the appropirate class and set all the properties in the "Leave" event of second page, and I use the "Enter" event of third page to use these values.
The problem is how can I tell the third page,which class to instantiate and how can I transfer these values(class properties on second page) to third page.
I am thinking may be the phone class has to be a singleton so that whenever it is instantiated I get the first instance each and everytime.
Is there a better way of communicating data between pages?
Thanks,
|
|
|
|
|
jerrymei wrote: Is there a better way of communicating data between pages?
MVC design[^]
|
|
|
|
|
string translationText = "";
if(dicText.TryGetValue(translation[r].EntryCode, out translationText))
{
dicText.Add(translation[r].EntryCode, translationText);
}
I don't get this method. As far as I understand it, it should do one lookup and if found then assign the related value of "translation[r].EntryCode" to translationText. Is this correct?
|
|
|
|
|
TTFCAFO or RTFM or STFW or ...
Just type the code and time it and see what works best. Thats what we do when we don't know the answer.
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
|
|
|
|
|
honeyman_can wrote: Is this correct?
If you mean TryGetValue(..), yes.
You should continue your original thread on a topic rather than starting new ones every few hours.
|
|
|
|
|
Im trying to create an access database with ADOX. It is to contain 3 tables,
each with a primary and foreign key and a one-to-one relationship between
each table.
I have no problem creating and populating the tables, no problem adding indexes to each table (one index is also a primary key). When I try to add primary keys
to any tables that do not already have one, it bombs out.
I've scoured everything I can find on ADOX (most of its VB) and nothing helps and
some examples I found were bad or confusing.
I'm also not sure if simply creating the primary/foreign keys will create a relationship of if there is something else I must do.
I've posted my code below with comments on the problem areas, I appreciate
any help (while I still have hair left) !
-------------------------------------------------------------------------------
<br />
public static void CreateDb(string fileName)<br />
{<br />
<br />
ADOX.CatalogClass cat = new ADOX.CatalogClass();<br />
ADOX.Table tblNew = new ADOX.Table();<br />
ADOX.Index tblIdx = new ADOX.Index();<br />
ADOX.Key tblKey = new ADOX.Key();<br />
<br />
try<br />
{<br />
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Jet OLEDB:Engine Type=5");<br />
tblNew.Name = "Customers";<br />
tblNew.ParentCatalog = cat;<br />
tblNew.Columns.Append("CustomerID", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("MachineType", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Name", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Address", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("City", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("State", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Zip", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Country", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Status", ADOX.DataTypeEnum.adWChar, 50);<br />
cat.Tables.Append(tblNew);<br />
tblNew = null;<br />
<br />
tblNew = new ADOX.Table();<br />
tblNew.Name = "Drawings";<br />
tblNew.ParentCatalog = cat;<br />
tblNew.Columns.Append("CustomerID", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("DrawingNumber", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("DrawingTitle", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("DrawingDate", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("FileName", ADOX.DataTypeEnum.adWChar, 255);<br />
cat.Tables.Append(tblNew);<br />
tblNew = null;<br />
<br />
tblNew = new ADOX.Table();<br />
tblNew.Name = "Revisions";<br />
tblNew.ParentCatalog = cat;<br />
tblNew.Columns.Append("DrawingNumber", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("RevisionLetter", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("RevisionDate", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("RevisionNote", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("RevBy", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("CheckBy", ADOX.DataTypeEnum.adWChar, 50);<br />
tblNew.Columns.Append("Key", ADOX.DataTypeEnum.adWChar, 50);<br />
cat.Tables.Append(tblNew);<br />
tblNew = null;<br />
}<br />
catch (Exception ex)<br />
{<br />
Utilities.InfoMessageBox(ex.Message);<br />
}<br />
<br />
try<br />
{<br />
tblNew = cat.Tables["Customers"];<br />
tblIdx.Name = "CustomerIndex";<br />
tblIdx.Unique = true;<br />
tblIdx.PrimaryKey = true;<br />
tblIdx.Columns.Append("CustomerID", tblNew.Columns["CustomerID"].Type, tblNew.Columns["CustomerID"].DefinedSize);<br />
tblNew.Indexes.Append((object)tblIdx, null);<br />
tblIdx = null;<br />
tblNew = null;<br />
tblIdx = new ADOX.Index();<br />
<br />
tblNew = cat.Tables["Drawings"];<br />
tblIdx.Name = "DrawingsIndex";<br />
tblIdx.Unique = true;<br />
tblIdx.Columns.Append("DrawingNumber", tblNew.Columns["DrawingNumber"].Type, tblNew.Columns["DrawingNumber"].DefinedSize);<br />
tblNew.Indexes.Append((object)tblIdx, null);<br />
tblIdx = null;<br />
tblNew = null;<br />
tblIdx = new ADOX.Index();<br />
<br />
tblNew = cat.Tables["Revisions"];<br />
tblIdx.Name = "RevisionsIndex";<br />
tblIdx.Unique = true;<br />
tblIdx.Columns.Append("Key", tblNew.Columns["Key"].Type, tblNew.Columns["Key"].DefinedSize);<br />
tblNew.Indexes.Append((object)tblIdx, null);<br />
tblIdx = null;<br />
tblNew = null;<br />
}<br />
catch (Exception ex)<br />
{<br />
Utilities.InfoMessageBox(ex.Message);<br />
}<br />
<br />
<br />
try<br />
{<br />
tblNew = cat.Tables["Drawings"];<br />
tblKey = new ADOX.Key();<br />
tblKey.Name = "2nd";<br />
tblKey.Type = KeyTypeEnum.adKeyForeign;<br />
tblKey.RelatedTable = "Customers";<br />
tblKey.DeleteRule = RuleEnum.adRINone;<br />
tblKey.UpdateRule = RuleEnum.adRINone;<br />
tblKey.Columns.Append("CustomerID", tblNew.Columns["CustomerID"].Type, tblNew.Columns["CustomerID"].DefinedSize);<br />
tblKey.Columns["CustomerID"].RelatedColumn = "CustomerID";<br />
tblKey = null;<br />
tblNew = null;<br />
}<br />
catch (Exception ex)<br />
{<br />
Utilities.InfoMessageBox(ex.Message);<br />
}<br />
<br />
try<br />
{<br />
tblNew = cat.Tables["Drawings"];<br />
tblKey = new ADOX.Key();<br />
tblKey.Name = "1st";<br />
tblKey.Type = KeyTypeEnum.adKeyPrimary;<br />
tblKey.Columns.Append("CustomerID", tblNew.Columns["CustomerID"].Type, tblNew.Columns["CustomerID"].DefinedSize);<br />
tblNew.Keys.Append((object)tblKey, ADOX.KeyTypeEnum.adKeyPrimary, (object)tblNew.Columns["CustomerID"], "Drawings", "CustomerID");<br />
tblKey = null;<br />
tblNew = null;<br />
}<br />
catch (Exception ex)<br />
{<br />
Utilities.InfoMessageBox(ex.Message);<br />
}<br />
<br />
if (tblIdx != null)<br />
tblIdx = null;<br />
if (tblKey != null)<br />
tblKey = null;<br />
if (tblNew != null)<br />
tblNew = null;<br />
if (cat != null)<br />
cat = null;<br />
}
|
|
|
|
|
We have a checkbox column in our DataGridView. If it is checked and then you move out of the row, we get the EndEditEvent. But is there another, earlier, event we can bind to that will let us respond to the checking of the checkbox immediately?
Thanks.
|
|
|
|
|
How about CellValueChanged?
|
|
|
|
|
Hi,
I have developed an application that i want user to download from my web site. Now the problem is that when user comes to my site, then is there any way that i could determine whether .Net 2.0 is installed on his system or not? I know it is possibe because Microsoft has implemented same feature on there SQL Express edition download page. If you go there, if you have .Net 2.0 installed, they tell you that you have .Net 2.0 installed. I want to know how it is possible? Please guide me in this regard.
Regards,
Wasif Ehsan.
|
|
|
|
|
How do I set the build properties so I can build a 2003 (v1.1) managed-code class library from VS2005 ? Thx.
|
|
|
|
|
|
Thx. I use NUnit all the time, do you like FXcop???
|
|
|
|
|
Any Regex guru's in the house?
I have a string coming from a database. This string represents some name/value pairs that are input by a Lotus Notes database and are delimited by two characters: '-' and ';'. The problem is the second part of the string allows both of the delimiters in the value field, so I can't use a Split(). What I need to do is first split the string to get the name/value pairs and then split it again to get the name and the value.
The string coming from the database looks something like this:
1234 - asdf-is a sample;2456 - eqwrt;7890 - ujk;l;097 - uio
And the array results should be something like so:
(I added the pipe symbol to make it easier to read)
1234 | asdf-is a sample
2456 | eqwrt
7890 | ujk;l;097 - uio
I can't figure out the syntax to split using a lookahead from the first '-' and the last ';' found before the next '-'.
|
|
|
|
|
I'm a little confused on your pattern here. The last name/value pair is what concerns me. You have it as:
7890 | ujk;l;097 - uio
But your own pattern suggests that this should be two pairs:
7890 | ujk;l
097 - uio
Is this a correct assumption on my part?
If it is, I did manage to find a way to separate this stuff out. What I did first was reversed the input string so it looks like this:
oiu - 790;l;kju - 0987;trwqe - 6542;elpmas a si-fdsa - 4321
Then I used the regular expression:
;?.*?\s*-\s*\d+
This yields the following:
oiu - 790
;l;kju - 0987
;trwqe - 6542
;elpmas a si-fdsa - 4321
If you remove the semicolon from the strings on which it appears and reverse them, it should work. You could also group the match and pull the contents of the group:
;?(.*?\s*-\s*\d+)
Logifusion[^]
|
|
|
|
|
Yeah, that was a typo on my part. Thanks for your help!
|
|
|
|
|
Also, if you know there are no digits in your second value you can use
(\d+) \s+ - \s+ ([^\d]*)
Works with your example anyway.
Dustin's didn't work for me, maybe I'm using different RegexOptions ...
|
|
|
|
|
Hi,
I have seach but can't find a tutorial, which shall do the following:
I have a datagridview, which have 5 colomns - the first 4 I gets from a database. The 5. have I created as a unbound text.
In each row I will use the 5. column to make a calculation on column 1 and 4 where I shall say: column4 = column1 * column4
In a textbox below the datagridview, I then will have that adds all the data in column5
Example:
Column1.......Column2.....Column3......Column4......Column5
QTY...........Some text...Some text....Rate.........QTY*Rate
5.............aaa.........aaaa.........100..........500,00
2.............bbb.........bbbb.........150..........300,00
Textbox which contains the totally of Column5 = 800,00
Can anybody help me with a tutorial which contains these things?
Kind regards,
simsen
|
|
|
|
|
I try to explain me in another way;
First, I make a mistake, not to say, I'm only familar with C#. Second, I don't know where to put the code - on which event it should occour.
So I don't make the mistake again... I am using VS 2005. It's a Windows Form and I have added a new column on the datagridview.
I need a function that calculates each row in the datagrid and shows the result on each row in the column I added and a function which calculates the column I have added and shows it in a textbox.
Kind regards,
simsen
|
|
|
|
|