|
Please don't - it's very bad form and unfair on others who have posted. More importantly, it means that any attempt to answer here or in your other question will lead to having fragmented answers - which is bad for others who may have similar problems in the future.
The original thread is here[^].
|
|
|
|
|
Hi All,
I have a 90 column excel which may contain upto 200 rows which needs uploading into SQL database. Initially we designed an SSIS package that was actually very efficient. But just before our code went live we came to know that SSIS or DTS packages cannot be run on the production servers due to some security reason. But never mind, we did a overnight code to read the excel as dataset and then insert row by row using a parameterized stored procedure which is not at all efficient coding. Take hell lot of time to load anyways.
Is there an efficient way of doing this?????
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Dear All,
I am trying to create a class to handle my custom config sections in my app.config file, but no matter what i tried, i always get this kind of error:
Unrecognized attribute 'name'. Note that attribute names are case-sensitive. (D:\Users\xxx\Documents\Visual Studio 2005\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.vshost.exe.config line 10)
I had spent about half days to try to fix this annoy error but without any luck. can someone in here shed me a light will be greatly appreciated.
This is my app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="packageVersionSection">
<section name="packageVersion" type="ConsoleApplication2.Class1, ConsoleApplication2" />
</sectionGroup>
</configSections>
<packageVersionSection>
<packageVersion>
<package name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />
<package name="RPU Applications" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWinApps" />
<package name="Shared Applications" version="1.1.2.0" location="C:\Program Files\TeleMedCare\SharedApp" />
</packageVersion>
</packageVersionSection>
</configuration>
and this is my source code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
namespace ConsoleApplication2
{
public class Class1: ConfigurationSection
{
[ConfigurationProperty("package")]
public PackageVersionCollection PackageVersionItems
{
get
{
return ((PackageVersionCollection)(base["package"]));
}
}
}
[ConfigurationCollection(typeof(PackageVersionElement))]
public class PackageVersionCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new PackageVersionElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((PackageVersionElement)(element)).Name;
}
public PackageVersionElement this[int idx]
{
get
{
return (PackageVersionElement)BaseGet(idx);
}
}
}
public class PackageVersionElement : ConfigurationElement
{
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get
{
return ((string)(base["name"]));
}
set
{
base["name"] = value;
}
}
[ConfigurationProperty("version", DefaultValue = "", IsKey = false, IsRequired = true)]
public string Version
{
get
{
return ((string)(base["version"]));
}
set
{
base["version"] = value;
}
}
[ConfigurationProperty("location", DefaultValue = "", IsKey = false, IsRequired = true)]
public string Location
{
get
{
return ((string)(base["location"]));
}
set
{
base["location"] = value;
}
}
}
}
|
|
|
|
|
It is hard to read your code, can you tag it up please.
AFAICT, This is what defines the element package
[ConfigurationProperty("package")]
public PackageVersionCollection PackageVersionItems
{
get
{
return ((PackageVersionCollection)(base["package"]));
}
}
It should contain a sub-element containing a list of PackageVersionItems . But your config does something different:
<packageVersionSection>
<packageVersion>
<package name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />....
The package is an element in the collection. You also define a "name" property here this isn't in the class I've copied. As a rule of thumb, you should make sure your class names always tally up with the property names you intend them for.
[edit] fixed the XML markup so it would actually display, haven't done that in a while
|
|
|
|
|
It is the issue with my bloody xml file, it should be like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="packageVersionSection">
<section name="packageVersion" type="ConsoleApplication2.Class1, ConsoleApplication2" />
</sectionGroup>
</configSections>
<packageVersionSection>
<packageVersion>
<packages>
<add name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />
<add name="RPU Applications" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWinApps" />
<add name="Shared Applications" version="1.1.2.0" location="C:\Program Files\TeleMedCare\SharedApp" />
</packages>
</packageVersion>
</packageVersionSection>
</configuration>
I just missed the 'packages' element in my previous posting and i should use 'add'. Thanks a lot for ur help anyway.
|
|
|
|
|
Easily done, at least it's fixed!
|
|
|
|
|
hi!
IHi
i want to merge two or more text files.i.e. the content of the second file has to append to the content of the first file.
e.g. abc.doc, ab.doc and xyz.doc i want all three files merged in abc.doc
give me idea , how can i do this.
thanx with regards,
modified on Wednesday, October 6, 2010 12:52 AM
|
|
|
|
|
You can use FileStream for that.
rahul
|
|
|
|
|
Word Files? ... Good Joke
|
|
|
|
|
No, you can't. You'll be screwing up the content of the second file because you just appended all the Word headers and data (before the content) to the end of the first document, which Word will not expect.
|
|
|
|
|
|
This may come as a surprise, however a Word document is not a text file; it is a complex file that, to all intents and purposes, contains text, but also graphics and images, formatting, page layout information, table of contents, headers and footers, foot notes, possibly revision information, and lots more. You can't concatenate two of those, only a very Word-savvy user can, and he would have to make some tough choices while doing so.
|
|
|
|
|
When you say merged, what do you mean? Do you just want the documents appended to each other? What I would do, if I were you, would be to use word automation to open abc.doc and then the other two files; use select all and copy from the other two documents, and move to end and paste in abc.doc.
|
|
|
|
|
hi
Can u please tell me the real life example for the begin init and end init utilization in datatable and in which situation it should be used.
Thanks
|
|
|
|
|
If you want to change multiple properties of the DataView object but don’t want the changes to affect the data visible through the DataView until you’ve changed all of the desired properties, you can use the BeginInit and EndInit methods.
For example, say you have a DataView bound to a particular DataTable and you’ve also set the DataView object’s RowFilter property so that only a small fraction of the rows are visible through the DataView. You’re displaying the contents of the DataView on a Windows form using a DataGrid, and based on input from the user you want to change the settings of the DataView object’s Table and RowFilter properties. In this situation, you should enclose the code that changes the DataView object’s properties within calls to the DataView object’s BeginInit and EndInit property to prevent the DataGrid from momentarily displaying all rows from the new DataTable.
http://www.koopoo.cn/ASPNET/ADONET/adonethtml/32ch10f.htm[^]
rahul
|
|
|
|
|
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:
public string GetWebText()
{
byte[] data;
mshtml.HTMLDocumentClass ms;
string strHTML;
mshtml.IHTMLDocument2 objMyDoc;
string innerText;
TextWriter tw;
FileInfo fi;
int count = 0;
Encoding curEncoding = Encoding.GetEncoding(1256);
string htmlEncodingString = null;
CookiedWebClient wc = new CookiedWebClient();
fileName = path + curLangStr +".txt";
FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
tw = new StreamWriter(ostrm, curEncoding);
int j = 0;
try
{
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
}
}
catch (Exception e)
{
Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
tw.Close();
wc.Dispose();
}
return "";
}
modified on Tuesday, October 5, 2010 5:08 PM
|
|
|
|
|
I'm not seeing things well here, you really should show formatted code, using PRE tags. However it seems
Meneedhelp wrote: objMyDoc.write(strHTML);
is not taking any encoding into account.
|
|
|
|
|
I am not sure I understand.
objMyDoc is mshtml.IHTMLDocument2 object which I am using to extract the body of the HTML text. This text is saved in the string "innerText". It appears correctly to this point. But when I write this text to a .txt file, the text file contains garbled characters.
|
|
|
|
|
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:
public string GetWebText()
{
byte[] data;
mshtml.HTMLDocumentClass ms;
string strHTML;
mshtml.IHTMLDocument2 objMyDoc;
string innerText;
TextWriter tw;
FileInfo fi;
int count = 0;
Encoding curEncoding = Encoding.GetEncoding(1256);
string htmlEncodingString = null;
CookiedWebClient wc = new CookiedWebClient();
fileName = path + curLangStr +".txt";
FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
tw = new StreamWriter(ostrm, curEncoding);
int j = 0;
try
{
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
}
}
catch (Exception e)
{
Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
tw.Close();
wc.Dispose();
}
return "";
}
|
|
|
|
|
I'm not sure what you are attempting with CookiedWebClient and HTMLDocumentClass. I would suggest you try replacing
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
by
data = wc.DownloadData("http://www.alarabonline.org");
strHTML = curEncoding.GetString(data);
tw.Write(strHTML);
to see how that works out. I expect it will handle Arabic text well.
I am puzzled by you casting an HTMLDocumentClass to IHTMLDocument2; and by the compiler accepting your objMyDoc.write(strHTML) statement, as write expects an array of BSTR, not a string.
I would suggest you try and solve your functional requirement based on System.Windows.Form.HtmlDocument
|
|
|
|
|
Meneedhelp wrote: but the output file contains weird characters.
And how exactly did you 'see' those characters?
In other words you used something to view that file. What did you use? And how did you validate that that method would display the characters correctly in the first place?
|
|
|
|
|
I opened up the txt file which I am writing into.
The method displays characters correctly for Spanish, Italian, Hindi and Thai when I replace the http link and the encoding.
|
|
|
|
|
From my WinForm application I have a need to call javascript function from a WebBroswer control using something like this:
webBrowser1.Document.InvokeScript("show_line",...);
The show_line function is in javascript and looks like this:
function show_line(points)
{
for(var i=0;i<points.length;i++)
{
}
}
In other words, the parameter points is an array. My questions is how to pass an array of double from C# to javascript using
webBrowser1.Document.InvokeScript("show_line", points);
Thanks!
modified on Wednesday, October 6, 2010 11:33 AM
|
|
|
|
|
I'm trying to figure out how to set up the inside vertical & inside horizontal line to be setup as hairline weight.
That's what I have for now to setup the line for inside vertical and inside horizontal.
cellRange = oSheet.get_Range(oSheet.Cells[excelRow + 2, excelColumn + 3], oSheet.Cells[excelRow + 6, excelColumn + 7]);
cellRange.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;
cellRange.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlContinuous;
Question is how do I set up the line weight to be hairline?
-- Modified Tuesday, October 5, 2010 2:59 PM
|
|
|
|
|
Try Excel.XlLineStyle.xlSlantDashDot;
For a list of supported styles, see here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|