|
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
|
|
|
|
|
I don't know if this will fully help but an excellent datagrid tutorial is on the CodeProject and written in 4 parts by Pete2004. Search for that, or for, "A Practical Guild to .NET DataTables, DataSets and DataGrids".
|
|
|
|
|
I any should have the same question.
The solution is:
// Databinding for the Grid
da2 = new OleDbDataAdapter("SELECT Ordre.Antal, Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER JOIN (Faktura INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn);
da2.SelectCommand.Parameters.Add("@fakid", OleDbType.Integer);
da2.SelectCommand.Parameters["@fakid"].Value = fakid;
//create datatable
dtOrdrelinier = new DataTable();
//fill datatable
da2.Fill(dtOrdrelinier);
//create colum to hold the sum of other two colums
DataColumn col = new DataColumn("RaekkeBeloeb");
col.DataType = typeof(System.Decimal);
col.Expression = "Antal*PrisExMoms";
//add the colums
dtOrdrelinier.Columns.Add(col);
//Get the sum of the all totals
txtBelob.Text = dtOrdrelinier.Compute("Sum(RaekkeBeloeb)", "").ToString();
//bind datatable to grid view
dgrOrdre.DataSource = dtOrdrelinier;
|
|
|
|
|
my problem is that when I create a report (or a crystal report) rendering takes a huge amount of time (I have 30 000+ pages in this report after I use print preview)
Can I get any suggestions of how to overcome this problem?
Is this possible?
drinking beer is fun
|
|
|
|
|
30,000 is a large number. Most games try to acheive at least 30fps and old ones on modern machines achieve over 100fps.
Besides, real-time is much faster than one second.
Real Answer: If you want a real-time report make it smaller so the real-time use can use it. No one can use a 30,000 page report faster than it can be displayed.
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
|
|
|
|
|
Typically when building out a large amount of data like that, the time is not spent rendering data, but getting the entire shooting match in one shot.
An alternative (outside of Crystal Reports) would be to limit your display to a set number of rows and then handling the paging yourself. So the page forward would request items(currentHigh) to items(nextHigh) and page back would request items(nextLow) to items(currentLow).
You could tie things together by having the report generation occur in a separate thread so that as you display page 1, it is loading 2-1000 while the user decides to go to page 2, then on and on until the thread is done creating the data.
It will definitely increase the perception of speed while doing the same task.
|
|
|
|
|
i am doing a windows desktop application in C#.
In this project when I select a folder i want to traverse through its subfolders and files to the leaf level. How can i do this in C#.
I am selecting folder using FolderBrowserDialog.
I am stuck after that.. how can i gets its fils and subfolders.
I VB 6.0 and all we have files sytem and folder objects to travese. Here what we have to do?
hope i will get a reply soon
...thanks
...hari
|
|
|
|
|
Use the DirectoryInfo class.
DirectoryInfo di = new DirectoryInfo(path);
FileSystemInfo[] fi = di.GetFileSystemInfos();
fi contains a list of all the folders and files in the directory represented by path. Now you can traverse through that list. Consult MSDN on DirectoryInfo class for further details
-------------
The primary aim of AI is to make programming languages understand how frustrating it is to program them
|
|
|
|
|
The FolderBrowserDialog.SelectedPath property contains the Path selected by the user. Everything else you need can be found in the System.IO namespace in particular Directory , DirectoryInfo , File and FileInfo classes.
"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
|
|
|
|
|
Thanks
It worked for me
|
|
|
|
|
Hello guyz,
I am using Enterprise Library 2.0 and trying to do logging in database. What I have found is that if I use a database where I have integrated security on I can use my database listener to use database for logging but when i use Integrated Security = false with user id = sa and password = abs then Enterprise Library doesnt do any logging in database.
I must use user from database e.g "sa" I am not suppose to use integrated security.
Any idea how can I do it?
Thanks in advance.
|
|
|
|
|