
Agent707
Members-
Posts
19 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Agent707
-
Wow, this forum doesn't get much action. 3 posts this year... including an 8 year old thread necro.
-
I have to confess the source of this problem came from Excel, not Jet. I never opened the .CSV file in notepad (shame on me) to verify the values were actually the long numbers. I just assumed, but not so. Apparently Excel is pretty dumb when it comes to saving files "as csv". It outputs the scientific notations (what is displayed) instead of the actual value of the cell. How wonderful. Open Excel, type in a really long number, hit enter (you'll see the cell value change) and save the file as csv. You'll see what I'm talking about. So I had to define the column as numeric (no digits) THEN export it to the CSV. I'll just have to make sure our vendor knows about this before they start sending the CSV files our way. All this headache for nothing. I do agree a custom CSV reader would be better than using JET, but this application is something that should have only taken about 4 hours total to implement... and I'm way over that margin right now, so I'm moving on to reporting. Thanks for sharing your thoughts.
-
I don't follow you - "load the file into a dataset directly". What do you mean by that? Reading the file manually line by line using a streamreader or something? I mean, that's what I'm doing using jet... loading it directly. I'm only using Jet to load up my dataset from the file (part a). At that point (part b), I'm going through and validating row by row and adding it to a new datatable, which I use a sqldataadapter to do a batch insert (stored procedure). Reporting invalid rows so they can be fixed in the file. Part b works as intended. However, I did change my method of inserting the data. Instead of using the sqldataadapter to batch insert, I used the SQLBulkInsert method. Works much faster, and no store procedure required. This does nothing though for my problem though (part a). Please elaborate on what you meant by the quoted statement. And thanks for the SQLBulkInsert tip.
-
K, I'm not sure which forum this question goes in, so I am putting it here. Probably a database forum thing though... Here's my problem. I have a customer file [CSV] I am importing to SQL. I am using JET to read it into a dataset. I am using a schema.ini file to define columns, because I have one column with up to 1000 characters in it... so I have to define it as a Memo field so it won't truncate at 255 characters. ANYWAY, I have one other column that has VERY large numbers in it. i.e. 4671070409010930000 This is, in effect an 8 byte integer. My problem is, I can't seem to get it into my dataset without it *****ing the value. I can't define it as any kind of numberic type in my schema ini, as there is no decimal type. If I define it as long, I get an eroneous value. If I define it as double, I get overflows. If I define it as text (Which I thought the logical answer), I get '4.67E+18'...????? which SQL can't convert to anything numeric. Even if it could, I loose a lot of the value due to precision. Is my problem understood? Any idea's? I need to get it into my dataset as TEXT without it changing it to '4.67E+18'. SQL can convert '4671070409010930000' to a decimal(19,0). It can't convert '4.67E+18' to Anything. I don't think it's the end of the world if I can't get this column imported. They aren't asking for it to be displayed on the report (reason for import). Here's my code that reads it into a ds. Private Function GetDataSetFromFile() As DataSet Dim oleDBCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data" & _ " Source=" & mWorkingImportDirectory & _ ";Extended Properties=""Text;HDR=Yes;FMT=Delimited""") Dim oleDbDA As New OleDbDataAdapter() Dim ds As New DataSet Dim oleDbCmd As New OleDbCommand("SELECT * FROM " & mImportFile, oleDBCon) oleDBCon.Open() oleDbDA.SelectCommand = oleDbCmd oleDbDA.Fill(ds, "CSV") oleDBCon.Close() Return ds End Function schema file. [importFile.csv] Format=CSVDelimited CharacterSet=ANSI ColNameHeader=True Col1=OrderDate DateTime Col2=SupplierName Text Width 100 Col3=ItemDescription Memo Col4=ItemQty Short Col5=ItemPrice Currency Col6=Subtotal Currency Col7=Freight Currency Col8=Tax Currency Col9=Total Currency Col10=AccountCode Long Col11=ProjectNumber Text Width 19 <----- This is the problem child. changing this number has no affect. Col12=CostCenter Text Width 10 Col13=BusinessPurpose Text Width 30 Col14=ReferenceNumber Text Width 20 Col15=InvoiceNumber Long Col16=ShipDate DateTime Col17=ReceivedDate DateTime
-
I use this all the time. You can apply styles to it to make it look like what you want it to also. <input type="text" value="blah" readOnly="true" onclick="alert('foo');" />
-
LOL! I just realized the structure of the 2nd document I posted is exactly the same as the one you had to begin with. Late in the day, what can I say but... Oh well.. Good that you're going on it now. Cheers :)
-
It is probably in this line NodeList = doc.GetElementsByTagName("GetVehicle") It's GetVehicles not GetVehicle For starters, you need to understand the structure of an XML Document. Nodes (Or tags as some prople call then) have a hierachy depending on where they are at. Your document would look this if you indented it correctly. <?xml version="1.0" encoding="utf-8" ?> <GetVehicles release="8.1" environment="Production" lang="en-US"> <ApplicationArea> </ApplicationArea> <DataArea> <Error></Error> <Vehicles> <Vehicle> <Combined_Make>VOLVO</Combined_Make> <Combined_Model>70 SERIES C70 T5 GT</Combined_Model> </Vehicle> </Vehicles> </DataArea> </GetVehicles> Another major thing. Combined_Model and Combined_Make are not attributes, they are Nodes. Release, Environment and Lang are attributes (of GetVehicles) You have to parse your nodes in the hierarchy they occurr in your document. See if this makes sense Dim objNode As XmlNode Dim GetVehiclesNode As XmlNode Dim VehicleNode As XmlNode 'Get the root node of your document (where the release number matches if you want to). GetVehiclesNode = doc.SelectSingleNode("GetVehicles[@release='8.1']") 'Now get the Vehicle node that is nested down in your document like so. VehicleNode = GetVehiclesNode.SelectSingleNode("DataArea/Vehicles/Vehicle") Dim strNodeElement As String Dim strNodeText As String For Each objNode In VehicleNode strNodeElement = objNode.Name strNodeText = objNode.InnerText Next Now, if you want your XML Document to have a more sensable structure, should probably do something more like this <?xml version="1.0" encoding="utf-8" ?> <GetVehicles release="8.1" environment="Production" lang="en-US"> <ApplicationArea> </ApplicationArea> <DataArea> <Error></Error> <Vehicles> <Vehicle> <make>VOLVO</make> <model>70 SERIES C70 T5 GT</model> </Vehicle> <Vehicle> <make>BMW</make> <model>325i</model> </Vehicle> <Vehicle> <make>Volks Wagon</make> <model>Passat</model> </Vehicle> </Vehicles> </DataArea> </GetVehicles> Then the code would be more like 'Now get the Vehicles node that is nested down in your document like so. VehiclesNode = GetVehiclesNode.SelectSingleNode("DataArea/Vehicles") Dim strMake As String Dim strModel As String For Each objNode In VehiclesNode.SelectNodes("Vehicle") strMake = objNode.SelectSingleNode("make").InnerText strModel = objNode.SelectSingleNode("model").InnerText Next Hope that makes sense. Play with it and see how you do. I'm outter here for the weekend. Good luck!
-
How to filter a dataset in a For...Each loop?
Agent707 replied to Agent707's topic in Database / XML / Reporting
I don't see why you say "This shouldn't work"...? :confused: A Dataview object has a Table (DataTable) object, which has a Rows (DataRowCollection) object... It's a simple loop through the rows collection. And it works perfectly. -
One other thing... just a suggestion, but instead of doing this big sub call salesOrder = middleTier.placeOrder(stockStatus, canBeQueued, QuickLinx, Quantity, Price, BusinessName, HouseNoAndStreetName, Town, PostCode, CarriageType) Write a class and all these values you are grabbing in here and sticking in variables, set them into properties in your class, then when you have filled everything in... 'Same code above, except wrap around it... With YourClassName For Each 'Blah.... .OrderNumber = OrderXMLChild.Attributes("SONumber").Value .StockStatus = xmlNode.SelectSingleNode("StockStatus").InnerText 'etc. etc. 'place the order .PlaceOrder Next End With We do things very similar to this here. This type of code is very easy to maintain. Good luck. :)
-
Not real sure why all for for each loops you're doing. You only need to loop through each "Order" it looks like. I just use a Node variable for each node inside your Order... Try something like this. Dim OrdersXMLRoot As XmlNode Dim OrderXMLChild As XmlNode Dim xmlNode As XmlNode OrdersXMLRoot = order.SelectSingleNode("Orders") For Each OrderXMLChild In OrdersXMLRoot.SelectNodes("Order") 'Get Order Number OrderNumber = OrderXMLChild.Attributes("SONumber").Value 'Order Configuration xmlNode = OrderXMLChild.SelectSingleNode("OrderConfiguration") StockStatus = xmlNode.SelectSingleNode("StockStatus").InnerText CanBeQueued = xmlNode.SelectSingleNode("CanBeQueued").InnerText 'Get product info xmlNode = OrderXMLChild.SelectSingleNode("Product") QuickLinx = xmlNode.SelectSingleNode("QuickLinx").InnerText Quantity = xmlNode.SelectSingleNode("Quantity").InnerText Price = xmlNode.SelectSingleNode("Price").InnerText 'Get Address info xmlNode = OrderXMLChild.SelectSingleNode("Address") BusinessName = xmlNode.SelectSingleNode("BusinessName").InnerText HouseNoAndStreetName = xmlNode.SelectSingleNode("HouseNoAndStreetName").InnerText Town = xmlNode.SelectSingleNode("Town").InnerText 'So forth and so on... Next What your doing here, is getting the node for each item (Configuration, Address, Product...etc.) and then getting the values from within each item of that node. Make sense?
-
I prefer a chainsaw. Makes a lot more noise. I like having bad habits. It adds character. And last but not least. I love to do things that people on message boards oppose. Just because I can. :D [edit] And BTW, there is no way a hacker would ever get into any of our internal programs... NO WAY. Because anyone smart enough to be able to do anything like that anyway, wouldn't work here. Period. Computer savvy people : Our users is like Car salesmen : Preachers It's just simply one extreme to the other. hehe
-
How to filter a dataset in a For...Each loop?
Agent707 replied to Agent707's topic in Database / XML / Reporting
My post count reflects my experience with .Net. :D This is my first attempt at a .net app using a database, so my knowledge on these datasets...etc. is kind of limited. But what you say sounds good. After messing with it a bit. I came up with this. oDataView = oDataTable.DefaultView For Each lo_node In lo_nodeSet.SelectNodes("attachments") lo_attachments = GetDataElement(lo_node, "attachments") ls_name = lo_attachments.GetAttribute("KeyName") oDataView.RowFileter = "name = '" & ls_name & "'" 'some code For Each oDataRow In oDataView.Table.Rows 'some code Next 'more code Next And works great. Thanks! These .net data objects are starting to click a little bit now. -
You say that without knowing the scope of this project. Kind of hard to make that assumption wouldn't you think? In this particular instance, it is the best way. And there is little security risk (trust me, there are FAR worse security issues where I work than this all. <shrugs>). Anyway, as the saying goes... there are umpteen ways to skin a cat... but in the end, you still have a <drum roll> skinned cat. :D I do appreciate the feedback on the OP.
-
I have a dataset with a column "KeyName". I need to filter my for each loop on this if I can. For Each oDataRow In oDataSet.Tables(0).Rows 'code Next Something like this... e.g. For Each oDataRow In oDataSet.Tables(0).Rows (where "KeyName = 'SomeValue'") 'code Next The reason I need to do this is THIS For Each loop is nested inside another one where I am looping though each "KeyName" in an XML Document. Looks like this. For Each lo_node In lo_nodeSet.SelectNodes("attachments") lo_attachments = GetDataElement(lo_node, "attachments") ls_name = lo_attachments.GetAttribute("KeyName") 'some code For Each oDataRow In oDataSet.Tables(0).Rows (where KeyName = ls_name) 'BUNCH of code Next 'more code Next Hope that makes sense. Thanks
-
Sounds like it just takes an allocated amount of memory and fills it like using Mid$. In some app in the past... just for speed purposes, I would declare a fixed length string (Dim someString As String * 64000) to use in string building. Then I'd fill it using Mid$() keeping up with where the start location is. Then dump it where I needed it and trimmed it up. The only problem was I had to make sure I never had more than 64k in data... or it was truncated. Interesting. Sounds like StringBuilder is the perfect resolution to the issue. Thanks again.
-
Huge SQL statements. Basically going through an XML and pulling fields out that need either Inserted, Updated, Deleted... building a SQL and executing it all at once. Kind of looks something like "Insert into blah....stuff...; Update blah from (select..stuff.. ) where blah... ; Update blah.... ; Delete from Blah...."...etc It's one of those programs where you gather the data from a large web form and begin a transaction... do it... if ALL of it runs without failure, commit. otherwise rollback. Sounds archaic, but it's really the only way to do this one app. Anyway, I had to do this project based on what I already know... The String builder class isn't part of my knowledge yet. This is one of those projects that had to be done a year ago, but they put it off... now it has to be done like YESTERDAY, if you catch my drift. I'll have to look into stringbuilder for future projects though. Back to work now. Thanks!
-
I have a couple of developers having a "discussion" about which is the more efficient way of doing string concatination... :-\ And when I say efficient, I mean "faster execution" wise. '#1 sVar = "This is some text " sVar += "and this is some more text " sVar += "...etc..." & someVar & " some more text" '....etc. on for a thousand lines... '#2 sVar = "This is some text " & _ "and this is some more text " & _ "...etc..." & someVar & " some more text" 'And every so many rows, 40 or 50?, add to it like so... sVar += "and another 40 or 50 so lines of text." & _ Now imaging this type of coding with a thousand lines instead of 3. I have always used method #2. This one guy has always used #1, though he says he "thinks" #2 is more efficient. The other guy is just a trouble maker and says everyone is wrong and he is right, but he has no opinion. :rolleyes: Does anyone have any "technical" explanation of which method is the preferred? IF there is any?
-
Weird problem. I'm trying to write a function to determine what Browser and version clients are using. Using HttpBrowserCapabilities ...pseudo code Dim bc As HttpBrowserCapabilities bc = Request.Browser Response.Write(bc.Browser & " " bc.Version) Works fine on IE. Show "IE 6" or "IE 5.5"...etc. Even works on Netscape 6.2. Shows "Netscape 6.2" Here's the Problem. On versions of Netscape 7 or greater, it shows the version as 5.0 "Netscape 5.0" I've tested it with 3 newer version. 7.2, 8.0 and 8.1 They all show "5.0" Even if I try to use the .Majorversion + .Minorversion. Same thing. When I pull the server vars for HTTP_USER_AGENT for each browser type, I get this. Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 (ax) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20050603 Netscape/8.0.2 Note: The first one returns the correct version (6.2) in my .Net app, where the second and third are returning the Mozilla version (5.0) Anyone have any ideas how I can resolve this?
-
I own 3 gaming computers... all of which have Athlon XP 3400++ speed cpu's (Overclocked of course) and Radeon 9800Pro's. I wouldn't trade them for any nVidia product. I'm not a Fan boy, just know what good hardware is :) I've owned many nVidia cards in my day (well, still own them, but they are stuffed in a shoe box somewhere. lol). The only nVidia card that can compare to the 9800 is the 5950XT, and it still looses in "quality". May be faster, but not as purdy. :D Get the 9800.