|
Load excel to a dataset then fill this dataset to DB.
a sample code snippet from net:
Dim ConnectionString As String <br />
<br />
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ <br />
"Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel 8.0;HDR=NO""" <br />
<br />
<br />
Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString) <br />
ExcelConnection.Open() <br />
<br />
<br />
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet8$]", ExcelConnection) <br />
Dim ds As New DataSet("Workbooks") <br />
<br />
<br />
da.Fill(ds, "Sheet8")
|
|
|
|
|
If I create a nested class based on Form or UserControl (see code outline at end of note) then VSE 2005 C# does not present a design surface with which I can work.
Same issue with Component based classes, although that's less of a problem as they tend to be less susceptible to change. Haven't tried DataSets but I assume they are the same. And there seems to be no way to nest Resource and Settings classes either. The rule seems to be that classes developed with designers cannot be nested.
Q1 What am I doing wrong (apart from daring to use nested partial classes)?
Q2 Is there a workaround?
Q3 Is it a VSE constraint, that's not manifested by other versions of 2005 VS C#.
Q4 If this is a common constraint, does that imply I could not create nested classes using the Class Designer provided in the Standard and Professional editions of VS 2005 C#.
myUserControl.cs
namespace myNamespace {
partial myOuterClass{
partial public class myUserControl : UserControl {
public myUserControl{
InitializeComponents()
}
}
}
}
myUserControl.Designer.cs
namespace myNamespace {
partial myOuterClass {
partial class myUserControl {
public myUserControl {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
.
.
.
private LastGadgetType lastGadget;
}
}
}
}
|
|
|
|
|
1 - your control needs to be the first class in the file in order to show in the design view
2 - See 1
3 - Not that I know of
4 - yes, there is a common constraint there in how you organise classes if the deigner is to work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks Christian, your answers are as I expected, but not what I wanted to hear.
What's the point of including nesting and partial classes if the tools don't support them. Are there any other C# IDE's that do support partial nested classes -don't bothering answering that I can google too.
Are you aware of any plans by MS to support partial nested classes etc in their designers in future versions of VS. I guess I could always write my own, I'm not planning on doing anything this evening
|
|
|
|
|
pjd1001 wrote: What's the point of including nesting and partial classes if the tools don't support them
It's got nothing to do with it. Two vanilla classes will kill the designer, if your control is not the first one.
pjd1001 wrote: don't bothering answering that I can google too.
*grin* I don't need to. I doubt any other IDE is going to be better than the MS one.
pjd1001 wrote: Are you aware of any plans by MS to support partial nested classes etc in their designers in future versions of VS.
No, I have no idea, and I doubt it's a priority.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
got another hammer out and did some panel beating - I can live with the result.
FYI I d'ld the ICSharp Open Source C# IDE, same problem. It's got a "prettier" editor, no data designer as far as I could make out. I does have better "out of the box" integration with "help system" and some documentation features, than I haven't seen in VS. And you get the source. Would I use it for life critical stuff, no, but nor would I use VS.
|
|
|
|
|
Can C# modify the OS (windows) item (eg.Date and Time) setting in the control panel?
How?
Thanks!
|
|
|
|
|
Are you looking to change system time using c# ?
|
|
|
|
|
NO, I want to modify the setting of 'Trigger Control' in the control panel in CE.
|
|
|
|
|
Hi,
I need to turn OFF the HTMLEncode property of a GridView Column dynamically i.e. when I'm reading from a Chinese database, i need to show "GB2312 Charset" characters.
I'm binding the GridView dynamically in code behind by its DataSource property. The only place where i could find access to the HTMLEncode property is when you explicitly create a Bound field (which i don't want to do). How do I turn off the HTMLEncode property of a Column in a GridView programatically??
Any help would be appreciated.
(if anyone knows how to display GB2312 characters in a Gridview by some other way ,that would be great too )
Thank you
Sanjot.
|
|
|
|
|
Hello,
I need a textbox control that operates like the "To" control in many email programs, (Outlook etc). I've had a good look around, but can't seem to spot one anywhere. I know I've posted this in General Discussions, but haven't received a response there. Sorry for the cross post.
If you understand how the To: or CC: etc controls in an Outlook New Mail operates, then you've basically got the requirements right there. It displays a list of objects, each represented by some underlined text. You can select, double click on the object's text, and it will display more information etc. You can drag and drop them between two similar controls (eg. from To to CC etc). Most importantly, you can't split up the text of an object - to the user, the text IS the object
I've got a good start on developing such a control, but I'm concerned about the full amount of support required for it. For example, undoing, intellitext etc. etc.
Thanks in advance for any help or pointers
Phil
|
|
|
|
|
This is definately something you need to write yourself. Undo is easy, just keep a history of what the user types in a list
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well i've almost go this treeview finished, it looks good now, got icons for different types of nodes, but when i click on a node, its icon gets changed to that of imageindex 0, and when i click another it changes back.
I don't know why it's doing this, but is kind of annoying, its not a priority or anything so...
|
|
|
|
|
Hello
TreeNode.ImgageIndex => Unselected state (You've done that!)
TreeNode.SelectedImageIndex => Selected state (You've forgot that!)
Regards
|
|
|
|
|
Aww, that means more effort.
Well thanks, you've saved quite a bit of time there.
|
|
|
|
|
Well i got this:
void TreeView1AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
this.treeView1.SelectedImageIndex = this.treeView1.SelectedNode.ImageIndex;
}
but it redraws the whole treeview (redraw, not rebuild) with a nasty flash, every time the SelectedImageIndex is changed, any way around this?
or do i just have to find another icon for the SelectedImageIndex?
-- modified at 20:38 Tuesday 22nd August, 2006
|
|
|
|
|
Hello
You should set the images when initializing the treeview for the first time only, not every time you select/unselect a node. Do this in your form's constructor, or the Form_Load event handler.
Besides you set the TreeNode.SelectedImageIndex, not TreeView.SelectedImageIndex. The latter is the default image displayed for any selected node, if the node doesn't have an images -will work fine if you have only one image for all selected nodes-.
Regards
|
|
|
|
|
I see, my mistake then
|
|
|
|
|
Happens all the time.
Why don't you post it Here[^]
Regards
|
|
|
|
|
Hi,
Does anyone knwo what the IsRequired property is supposed to do for the ConfigurationProperty attribute? If i omit a required property in the configuration file, it doesn't throw an exception nor does it go into OnRequiredPropertyNotFound -- what does setting IsRequired to true do then?
Thank you!
stephen
|
|
|
|
|
I know this sounds noob, but I'm missing something here and I can't figure out what.
I have a class (we'll call it myControl) that inherits from System.Windows.Forms.Control.
In myControl, I override OnPaint.
I then add an instance of myControl to a Panel, hoping to see it there. However, it doesn't show up. What am I forgetting?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Nevermind. I guess you can't set a Control's size in its own constructor (or, can you?). Anyway, I guess I need to look over my math...
Thanks anyway!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hello
Heritos Gger wrote: I guess you can't set a Control's size in its own constructor (or, can you?).
Sure you can!! Why not?
Regards
|
|
|
|
|
I guess you can after all. My math was wrong with what I was drawing, so I was drawing stuff outside the bounds of the control.
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Is it visible ? I'd expect to see it, too.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|