|
dabuskol wrote: Hope you could enlighten this.
Open the Excel-file (using ADO.NET, or any other library), read the content in a loop, write it to a database. Grids aren't a storage-point, they're used for displaying.
What exactly do you need enlightenment with? How to read Excel, how to save it, or the complete task?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
excel files are saved in a database for every record created.
What I need is to read this files of every record let say 10 records per run then automatically read the content of each file to a grid for display purposes.
In the end all the contect of 10 excel files is displayed in the grid for viewing.
no human intervention, automatic with a single button.
Regards
Dabsukol
|
|
|
|
|
dabuskol wrote: What I need
Who is saving the Excel files, what database? Sql Server? Oracle? Sqlite? Are they saved as a BLOB, or is it a real import? Do you want to "show" 10 excel-files (and their content) in a single grid? How?
You'll have to formulate your question with a bit more detail to get a decent answer. And that's what we do, answer questions - that's a bit different from "providing codez". Like your question is standing now, I'm very inclined to explain how to add a button to the form.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2010 desktop/console appplication, I would to know how to accomplish my tasks (or at least part of my taks) listed below working with xml:
1. I want to parse out specific nodes so that I can access the various level of nodes I am working with.
2. I would like to place various data elements in a collection/array that I can work with like an array.
3. I would like to take the xml file and add certain sections to a sql server 2008 r2 database.
**Note: The xml contains the various kind of stuctures:
a. There is an occurence of 0 to 50 customer names.
b. There is a node is just unique elements.
c. There is an occurences of 0 to 25 elements that contain the
following 4 items in each occurence:
customer number, customber address, customer city state and zip,
contact name, contact number.
Thus can you tell me and/or point to to references that will show me how to accomplish my goals (or at least part of the goals)? If I have at least an example or two to look at, I can figure out how to accomplish the rest of the goals.
|
|
|
|
|
sc steinhayse wrote: 1. I want to parse out specific nodes so that I can access the various level of
nodes I am working with.
An easy way to do this is to use Linq for XML. Take a look at this[^].
sc steinhayse wrote: 2. I would like to place various data elements in a collection/array that I can
work with like an array.
Using XLinq this is trivial. Read up on it and see how you can use things like ToList() or ToArray() .
|
|
|
|
|
Can you show mne more code examples than the link you pointed to?
|
|
|
|
|
Sure. You can find examples of querying XML here[^]. If you were to post a simplified sample of the data structure you are talking about, I could show you a sample query or two that would mean more in the context of what you're trying to do.
|
|
|
|
|
I have a process to print my sql database Id in zebra printing machine with Barcode using c# i am confused i dint use zebra printing machine before . Help
BigHeart
|
|
|
|
|
Unsurprisingly, I was able to find a C# implementation of printing to this device with a simple Google search. Here's[^] one result. In future, you should really try to search Google before posting here because you are going to wait for an answer here.
|
|
|
|
|
I am writing a C# 2010 application where I am obtaining a response from a web service and placing the data into a string called XmlizedString listed below.
private string serializeXML(object objToSerialize)
{
String XmlizedString = null;
MemoryStream mStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(objToSerialize.GetType());
XmlTextWriter xmlTextWriter = new XmlTextWriter(mStream, Encoding.UTF8);
xs.Serialize(xmlTextWriter, objToSerialize);
mStream = (MemoryStream)xmlTextWriter.BaseStream;
XmlizedString = U8ByteArrayToString(mStream.ToArray());
private String U8ByteArrayToString(Byte[] characters)
{
UTF8Encoding encoding = new UTF8Encoding();
String conString = encoding.GetString(characters);
return (conString);
}
My next step is to place what I have in the field called XmlizedString
into one or two sql server 2008 database tables.
Thus my question is how would you parse out the data that is in the
XmlizedString? Would you save the data to a text file?
Basically can you tell me how you would take the XmlizedString data and
get the parts I need for the database? I do not want to keep calling the
web service.
|
|
|
|
|
Maybe load it into an XmlDocument, pull out the parts you want, and store them? Maybe?
|
|
|
|
|
Either load it into an XDocument for Linq transformations, or an XmlDocument for traditional manipulation. You can do either from a MemoryStream so you don't have to use the file system.
|
|
|
|
|
Can you show me some code examples?
|
|
|
|
|
I don't have any to hand, no. Searching should turn something up, however.
|
|
|
|
|
Normally when you talk to web services you get something called a "proxy dll". A sort of wrapper that represents the objects in the web service and can be used as a normal reference. Is the webservice returning a (string) field containing XML or are you talking about the response itself?
V.
|
|
|
|
|
I am talking about the repsonse itself.
|
|
|
|
|
dcof wrote: into one or two sql server 2008 database tables.
That is inprecise.
If you want to store the xml into a column in a table, then you just do that.
If you want to parse the xml, then transform it, then save data from that into columns then that is what you need to do.
If you don't need to tranform it then SQL server can parse and insert xml directly.
|
|
|
|
|
I would like to parse an xml file using linq in a C#2010 application. Listed below you will find an example of an xml file I want to parse. I would like to use the code listed below to parse the an xml file. Thus I am wondering if you can show me how to use the code I listed below to parse the xml displayed below and/or show me code that will accomplish this goal?
The following is the code:
using System;
using System.Linq;
using System.Xml.Linq;
class Program
{
static void Main()
{
XDocument document = XDocument.Load(@"d:\test.xml");
var priceInfo = from e in document.Descendants("MPrice").Elements("Price")
let start = DateTime.Parse(e.Descendants("StartDt").FirstOrDefault().Value)
let end = DateTime.Parse(e.Descendants("EndDt").FirstOrDefault().Value)
where start < DateTime.Now && end > DateTime.Now
select new { Id = e.Parent.Element("Id").Value, ListPrice = e.Element("ListPrice").Value };
Console.WriteLine(priceInfo.FirstOrDefault().Id);
Console.WriteLine(priceInfo.FirstOrDefault().ListPrice);
}
}
The following is the metatag:
<ns2:RetsubPack serviceSuccessful="true" returnCode="0" xmlns:ns2="http://test1/test">
<statusDescription>Package Details retrieved Successfully</statusDescription>
<PackageDetails>
<Type>type2</Type>
<Category>dog</Category>
<ContName>Co 1</ContgName>
<TotalTrans>0</TotalTrans>
</PackageDetails>
<NumberOfDocuments>3</NumberOfDocuments>
<subDocuments attachmentId="xx1">
<DocumentMetadata>
<DocumentTypeCode>Spreadsheet1</DocumentTypeCode>
<PackageId>pkg1</PackageId>
</DocumentMetadata>
</subDocuments>
<subDocuments attachmentId="xx2">
<DocumentMetadata>
<DocumentTypeCode>Spreadsheet2</DocumentTypeCode>
<PackageId>pkg1</PackageId>
</DocumentMetadata>
</subDocuments>
<subDocuments attachmentId="xx3">
</ns2:RetsubPack>
|
|
|
|
|
I don't use Linq, so I can't help you there, but I do manipulate XML a bit, usually in an XmlDocument, so maybe I can with that?
|
|
|
|
|
LINQ, it has been a while, but if I see you're query and the XML file, the code does not resemble the XML file? (or am I missing something?)
Some questions:
1. What do you mean with "parse" exactly, what do you want to achieve?
2. Do you know LINQ to XML?
3. Am I right that the code does not relate to the XML and if so, what is the exact problem? What have you tried yourself?
V.
|
|
|
|
|
|
Hello All,
I am using a winapp form c# (.net4.0)to login and navigate deep into a webpage, upload a file, download a file. All this works successfully... MOST of the time. Everyonce in a while, when I hit the download button, the system seems to hang. Like a webpage that never fully loads. My goal here is if ALL the pages don't load successfully, then close all webbrowsers and re-try process. Anyone have any ideas to see if page is hung on loading. My first thought was to have some sort of timer to check, if doesn't load, then start over.
I am opening a webbrowser object inside my winform in c#.
Here's my idea and please feel free to rip apart with a better concept.
Concept is timer launches Invoke(naviFunction). If it gets to the end of naviFunction then just break loop and continue. However, if the webbrowsing hangs somewhere, then the 2 minute timer will get hit, and restart the whole process.
Then maybe put some counter and if it tries twice, completely stop program so I can investigate.
just to put a bit more background... in the navigating section I am launching 2 new short threads. they both finish before the end of the main navigation. I've put them in to handle pop up windows where the main code pauses when they are on screen.
So I've implemented and I'm a bit stuck on something.
When I put a normal process everything works successfully.
When I test a fake navigation hanging point... such as below.. The code does restart at 2 minutes and it completes the re-cycle successfully. The problem is when it is done. Instead of moving on in the code, (outside the timer area) it goes right back to the point where it originally got hung on. But since I already did it successfully I need it to exit out of the whole timer area. ANy idea what I'm doing wrong?
so I think I found where the problem lies but I don't know how to fix it.
the timer I am using... I used Invoke(new naviTimer(naviTimerFunction) to launch the section of navigation/download. So when the fake hang hits... then 2 minutes passes, it resets (like its supposed to). Then completes properly... soon as the navigation/download completes, I need it to go to the main code, but instead it hits the Invoke(naviTimer) again in the timer... and it goes back to where fake hanging originally paused and tries to continure from there. ideas??
maincode
{
x=0
dountil x<>0
start timer (timer launched instantly)
if naviTimerFunction completed, then break loop
stop timer
loop
...continue code
...continue code
...continue code
...continue code
}
timer()
{
reset timer interval to 2 minutes
Invoke(new naviTimer(naviTimerFunction))
}
naviTimerFunction
{
navigate
navigate (fake hanging point!!!)
navigate (start sub thread)
download (end sub thread)
navigate (start sub thread)
navigate (end sub thread)
stoptimer
}
tried a different way, used systems.timer.timer and before it even runs the first time it gives me error stating not a single thread. Cannot create webbrowser objects. Cant get that to work either..... ugh
|
|
|
|
|
I'm not sure if I understand your question correctly, but if your problem is that the Timer event handler keeps firing, you can disable the timer as the first line of code in your Timer event handler so that it does not fire again. You can again enable it when you need it (like when navigating a page).
Alternatively, you can use a BackgroundWorker to hit the url using a WebRequest/WebResponse pair and use the WebBrowser.DocumentText property to load the resulting markup in the RunWorkerCompleted event handler.
|
|
|
|
|
sorry about the confusion. the main problem is even after I hit timer.stop(), upon the timer stopping, the code continues where it left off. hope I am making some sense. On the thread from INVOKE... not the main thread like I wanted
|
|
|
|
|
Disabling the timer does not abruptly stop its already running event handler.
The only way to circumvent this problem is to periodically check if timer is enabled and then exit the code.
|
|
|
|