|
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
|
|
|
|
|
Thanks a lot Dennis.
It works.
See, I have integrated UIPAB v2.0 block into it.
And somehow it uses views to navigate between forms (part of the UIPAB framework). Learning something new everyday.
Stanley
|
|
|
|
|
sir,
i want to enable/disable user accounts in active directory using c#.net.
please help me
|
|
|
|
|
Hello All, I am pretty stumped on this one... Basically I created a database application that has a Crystal Reports Viewer as a feature, my viewer works and everything in my app runs fine, after my first deployment (with one crystal report created), the need for other reports came about. My problem is that I am now no longer able to open, create or modify a crystal report in Visual Studios 2003. In the solution explorer, it shows the report, but when I double click it or try to open it, I get a "Specified Module Could Not Be Found" error. Thats it???? I have been looking and looking and cant seem find anything... I think maybe a dll or merge module or something could have gotten corrupted or is missing, but, I have no idea where to begin... Any help would be appreciated...
Thanks,
Brandon
|
|
|
|
|
|
Having developed C++ with Visual Studio 6.0 for many years, I have just moved to C# and Visual Studio .NET 2003. Much to my disappointment, I have found no similar feature to the "source browser", specifically the features "base classes and members", "derived classes and member", "call graph", and "callers graph". These are invaluable tools when looking into and understanding new code.
My question is now, is there some way I can get what I want? Is there a feature hidden somewhere where I haven't found it, or is there some external tool that can do this? "Derived classes" and "callers graph" are considered most important.
Thanks for any suggestions!
************************
Peter Andersson
|
|
|
|
|
There's many ways, and some of which are included in VS.NET. There's the Object Browser which you can access from the View menu, as well as the Class View similar to the original Class View for VC++ (and works the same as VC++, which several enhancements). If you want to see the IL for a module or modules within your assembly, you can open your assembly in ildasm.exe that ships with the .NET Framework SDK, which is installed by default with VS.NET (under the program folder for VS.NET typically called FrameworkSDK).
There's also third-party controls like .NET Reflector[^] that can disassemble and decompile managed code, as well as generate callee graphs.
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 your suggestion, but I dont believe the Object Browser and Class View even do 10% of what I want.
In VS6, I could very quickly see which classes are derived from any other class (current project/BSC-file only of course). This particular feature is very useful when trying to grasp the complexity of a new software library for example. I got some 20K lines of undocumented code in my lap today and this feature alone would cut days from the time needed to learn the existing code.
Agreed, the BSC files had drawbacks, only beeing updated when compiling, could only use one at a time etc, but I still believe it was a better technology than the current.
Class View and Object Browser seems to me be doing the same thing, at least regarding my own code, and that is to show the base classes and the members, and that is all and well in itself, but not nearly enough.
HOWEVER, now that I am done complaining and have stated that things were better in the goold ol' days, I must say that the .NET Reflector does what I need. Its a little cumbersome to use, but I can live with that.
Thanks alot for pointing out this great tool for me!
(Now maybe you could suggest a good tool that draws class hierarchies too? )
************************
Peter Andersson
|
|
|
|
|
Hello All,
Quick question, i dont seem to beable to get the file.exists to work with a file that sits on a networked path. Ive triple checked the path. Now I am running this from an asp.net webservice, would I need to set up security for the asp.net user in the folder where the file exists on the network to get this to work properly?
Thanks!
Ryan
|
|
|
|
|
Yes File.Exists works on UNC paths and yes you have to grant permissions on that directory to whatever user context is running your code (or impersonate another user who already has permissions).
The ASPNET (the default account for ASP.NET) won't typically work, however, because it's a local user account. You need to either grant read permissions on the parent directory to Everyone (not necessarily List permissions, though) or change your machine.config file or the Web.config file in the application root to use a domain user account and password (be sure that you secure the Web.config file and don't index it if you configure the user in that file.
Depending on what you're doing, you could also impersonate whatever user is making the request by setting the <identity> configuration element data correctly (see the SDK documentation) and using NTLM authentication on the directory with no anonymous login enabled. There is documentation about how to do this in the .NET Framework SDK along with the documentation for the <identity> configuration element. If you're familiar with IIS and configuring ASP.NET this is not a problem.
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]
|
|
|
|
|