|
You can do this with ADO.Net. Just change the connection string to :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\myfiles\\myworkbook.xls;Extended Properties=\"Excel 8.0;\""
(note the escaped backslash and quote characters. Data Source needs to be full path to the workbook file, UNC paths are ok if you have sufficient permissions to the location).
Table Name will be the worksheet name with '$" appended (e.g [Sheet1$] ).
If the spreadsheed contains mixed numeric and text data in the same column, you may wish to add to the "extended properties part IMEX =1
( ";Extended Properties=\"Excel 8.0;IMEX=1\"") to force all the columns to map to string data types (otherwise things get ugly when a column is misidentified as numeric and a non-convertible string is encountered after the first 8 rows or so).
Good luck.
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
hi rob
thanks for the tips!
It helps a lot.
Appreciate it tons.
|
|
|
|
|
I am using the Novell.Directory.LDAP.dll v2.0.3600.0 taken from Mono v1.0.5.
This library is meant to have functionalities similar to .NET DirectoryServices, which unfortunately cannot be used with IBM Directory Server.
I tried binding using the following code:
ldapConn= new LdapConnection();<br />
ldapConn.Connect(txtServerAddress.Text,Int32.Parse(txtServerPort.Text));
and got the following error:
Connection.freeWhiteSemaphore(0): thread does not own the semaphore, owned<br />
by -2
It seems that the source of the error is from
Novell.Directory.Ldap.Connection.freeWriteSemaphore(Int32 msgId)\r\n .
Does anyone know why this happened and how to resolve it?
I'm using VS .NET 2003 on a WinXP Pro connecting to (1) ActiveDirectory
and (2) IBM Directory Server on Win2K.
[Edit]There is no problem connecting with LDAP.dll v1.0 that doesn't require Mono.Security.
I'm assuming the code resulting in the above problem has not been added.[/Edit]
Thanks,
Edbert
|
|
|
|
|
Turned out that Mono has 2 sets of DLLs for .NET Framework 1.1 and 2.0
Next time I should read more carefully what the difference between net_1_1 directory and net_2_0 directory is.
Edbert P.
Sydney, Australia.
|
|
|
|
|
Hello,
Is there a way for me to add comma separators to my numbers using some formatting option? (For example 151238.34 becomes 151,238.34 and 13752375.92 becomes 13,752,375.92 etc.) What formatting option should I use?
I see that I can use # as an integer placeholder so I can use something like "#,##0.00" but how about if the numbers are more than 4 digits long begore the decimal? Is there a formatting option I can use regardless of the size of the double?
Thanx
-Flack
|
|
|
|
|
You can use regular expressions to create this number format, it's a commonly documented problem. I dunno if it's possible with a formatting option.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
Not certain what is required when developing a packaging and deployment application for a C# windows program with several forms. First, when the application is built using the Build menu command, does it incorporate the forms into the executable itself, or do the forms need to be included individually into the application. If they are required to be individually included into the application, then is there perhaps some way that these files could ALL be converted to individual .dll files or even incorporated into a single .dll files, or something? It would seem to me that if each file were required to be included into the application individually, that they would be too vulnerable -- any suggestions?
Also, when the path to files are written in the code for your application, and the files are expected to be stored in "C:/windows/" directory, for example, the package and deployment folder for Windows could store the files in WINNT or in Windows based upon which operating system is loaded onto the client computer. Since the programmer does not know what operating system the user is utilizing, how would the programmer write the path information to where the files are expected to be installed by the installer? That is, is there some environmental variables code that would work with the package and deployment program in which the deployment application makes the determination where to store the files during installation, and the code path to the files would agree with that path decision? Is there some code like Application.windir() or something?
Third question. If an application required the installation of other applications, or even the .NET framework itself, does the package and deployment application provide a transparent way of installing these applications first without the end user realizing that they are being installed? We have all seen the applications that have several installation modules included, and they are considerably bothersome to the end user. I would like to install the other applications and even the .NET framework transparently without the end user knowing that it is occurring. That is, if the .NET framework is installed already, then ignore, else install. If the third party application is installed already, do likewise. Any ideas?
Would really appreciate the input on these questions, as I do believe that others would like to hear the answer as well. Thanks.
|
|
|
|
|
What forms are you talking about? Any forms or any other classes you defined in your assemblies will be in those assemblies. You need to add your assemblies to a folder, though, by opening the Folder editor from the View menu, then add project output (best, rather than file paths, since they establish build dependencies with the dependent projects). Now those files get installed. Windows Installer does not muck with your files and is not specific to the .NET Framework (it's used for most Microsoft applications and libraries, as well as many, many third-party applications and libraries). It will not "convert" into a single DLL.
If you want only a single DLL then you need to define all your classes in a single project. Once again, Windows Installer installs files, registry keys, etc. It does not change your compiled code.
You need to pick which folder the files go into using the Folder editor. You really need to start by reading the documentation if you're having trouble figuring out. Read Deploying Applications and Components[^] in the VS.NET product documentation, especially the walk-throughs.
Regarding your third question - as also documented for the Windows Installer projects that are included in VS.NET and are very limited, BTW - the .NET Framework is not installed by the Windows Installer package that is produced in VS.NET. You need to use or create a bootstrap application that installs the .NET Framework if necessary, the proceeds to install your application. Read Dotnetfx.exe Deployment Scenarios[^] in the .NET Framework SDK, specifically the Creating a Single Setup Project[^] sub-section.
In "Whidbey" (.NET 2.0) a bootstrapper will be included with the installer projects, as of beta 1.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,(new to programming)
I populate a datatable with a dataadapter
myDAdapter1.Fill(myDTableItems);
This is probably a silly question, but...
Is it possible to append the datatable data with the dataadapter?
I want to keep adding rows to the existing table using the dataadapter. This is probably not possible, or even a good idea?
PS - not needing to use the dataadapter to update the original database.
thanks,
Ron
|
|
|
|
|
That's the default behavior for DataAdapter derivatives if you read the .NET Framework SDK documentation for the class. Rows are added or refreshed (based on key information, if your DataTable defines key columns) when you fill an existing DataTable .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have question about browsable in propertygrid. I am trying to change browsable 's bool value bec sometimes it dont need to show all properties. Like sometimes First dont need to be browsable. I am well-aware that I cant change the browsable's value bec it need to be constant variable while it is run-time. what is your suggestions tht I can change browsable 's bool value while it is run-time?
For example:
for()
{
[Browsable(???)] or [SwitchBrowsable(type,propertyName,bool)]//////can be true or false
public string First
{
get { return m_strFirst; }
set { m_strFirst = value; }
}
[Browsable(???)] or [SwitchBrowsable(type,propertyName,bool)]///can be true or false
public string Second
{
get { return m_strSecond; }
set { m_strSecond = value; }
}
[Browsable(????)] or [SwitchBrowsable(type,propertyName,bool)]//////can be true or false
public string Third
{
get { return m_strThird; }
set { m_strThird = value; }
}
}
I made this function to change true to false from browable but it wont let
me to change bec it is readonly so it wont work or I may overlooking something.
public static void SwitchBrowsable(Type type, string propertyName)
{
try
{
object[] o = type.GetProperty(propertyName).GetCustomAttributes(typeof(BrowsableAttribute), true);
if (o != null && o.Length > 0)
{
BrowsableAttribute ba = o[0] as BrowsableAttribute;
bool test = ba.Browsable;
//ba.Browsable = !ba.Browsable;
test = false;
//ba.Browsable = false;
//ba.Browsable = !ba.Browsable;
}
}
catch(Exception error)
{
Debug.Assert(false);
//CExceptionLib.DisplayErrorMessage(error);
}
}
|
|
|
|
|
The most robust solution is to implement ICustomTypeDescriptor in your class that is selected in the PropertyGrid . For most methods you can just return the value from the corresponding TypeDescriptor method overload that takes a bool determining whether or not to query any ICustomTypeDescriptor (the parameter is called noCustomTypeDesc ), like:
TypeConverter void ICustomTypeDescriptor.GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
} For ICustomTypeDescriptor.GetProperties you can return a BrowsableAttribute with the value you want, or just simply replace the PropertyDescriptor for your property in question with your own implementation that returns true or false for IsBrowsable .
This allows you to customize what component model viewers like the PropertyGrid see.
Also noticed how I used an explicit interface implementation above. This is best for interfaces where you don't want the members to be visible in the code editor and without having to use the EditorBrowsableAttribute . This is also commonly done for ISerializable and many other interfaces. It's completely valid and the only way to implement two like-named methods with different signatures required by different interfaces.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello all,
I make a Method save some data but some of this arguments not available in every time use the method eg:
DataAccess(int x, float y,DateTime actual_Date)
How can i save x and y and save DateTime field null without value.
Thanks
Hay
|
|
|
|
|
You need to create another method that does not take a DateTime, then have the existing method call that one, if possible, and deal with the DateTime itself. Otherwise, you can pass in DateTime.Now if you like, but if that is not valid, you definately need another method, and you should definately factor out as much as you can between the two into a single, common method.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
What Christian is talking about is an overload:
void DataAccess(int x, float y)
{
DataAccess(x, y, DateTime.MinValue);
}
void DataAccess(int x, float y, DateTime actualDate)
{
} Since DateTime is a value type it cannot be null. It is fairly common, however, to use DateTime.MinValue to represent an invalid date since you will most likely not need to reference Midnight, Jan 1., 0001.
To note, in .NET 2.0 a new generic type - Nullable - is introduced for these particular problems. This would allow you to declare your method like so:
void DataAccess(int x, float y, Nullable<DateTime> actualDate)
{
} You can also replace Nullable<DateTime> with DateTime? (notice the question mark). To make the parameter optional, however, you still need to overload the method.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for you time and help
I removed the fields that it will be enter later from the method and marke this fields as Allow null in sql server and it workd fine.
and when i want to enter this fields later i will edite this tbl with the new value
is this right?
hay
|
|
|
|
|
Yes, if you don't want to input a data all the time, that sounds great.
Perhaps a seperate 'SetDate' method is what you need, or just a general update method that can take a date as one field to change.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm trying to create a dragging data cursor that can be dragged horizontally on an xy plotted graph. Currently, every time the cursor gets dragged, i have to redraw the entire plotted graph. Is there any way to simply redraw the cursor in its new position without redrawing the entire graph. The graph is currently created as a user control and the cursor is simply a line drawn in the control.
thanks
|
|
|
|
|
If you are responsible for drawing the graph then you need to take care to only draw the area specified in PaintEventArgs.ClipRectangle , which is the invalidated area of your control. The whole graph does not need to be repainted unless, of course, the clipping area covers the entire control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Does anyone know how program the Serial Port i.e. inizilization, read, and write in C#. I'm having some problems figuring this one out.
Thanks
mci84078
bryan@wilkinsbus.com
|
|
|
|
|
Although it may not help I just thought I'd mention that there is a new RS232 control in Visual Studio 2005. If you're able to develop using the beta version of VS.NET it may help.
|
|
|
|
|
Hi guys.
Assume I have the following situation.
I have two forms. Form1 and Form2. Both form has the same namespace.
And in Form1, I have a Panel1 control and a button1 control.
So when I click on button1 control, I want to add Form2 to Panel1.
For example sake:-
Instantiate it from Form1.
Form2 frm2 = new Form2();
Panel1.Controls.Add(frm2);
Now, at run-time, when i click on Button1 to instantiate those codes, I get, the following error msg...
"Cannot add a top level control to a control". Anyways around this ?
Stanley
|
|
|
|
|
You can't add a windows form onto a control like that. You can, however, create a user control and add it onto your panel. That might be what you're looking for...
|
|
|
|
|
jbx1828 wrote:
And in Form1, I have a Panel1 control and a button1 control.
So when I click on button1 control, I want to add Form2 to Panel1.
You've got to set the Form.TopLevel[^] property to false and the Control.Visible[^] property to true .
Form2 myForm = new Form2();
myForm.TopLevel = false;
myForm.Visible = true;
panel1.Controls.Add(myForm);
I think the effect is kind of weird. So just out of curiosity: what kind of application are you writing?
Best regards
Dennis
|
|
|
|
|