|
sorry my English is bad
DataSet ds=new DataSet();
IDbDataAdapter ida=helper.GetDataAdapter();
ida.MissingSchemaAction=MissingSchemaAction.AddWithKey;
ida.SelectCommand=helper.CreateCommand(conn,"select * from A;select * from B",CommandType.Text,null);/////////this row code CommandString error,what?
ida.Fill(ds);
i use access database
i think create many table of dataset
|
|
|
|
|
xiaoyuan wrote:
helper.CreateCommand(conn,"select * from A;select * from B",CommandType
IIRC, Access/Jet SQL doesn't support compound statements. Try breaking them up into two different calls:
ida.SelectCommand=helper.CreateCommand(conn,"select * from A",CommandType.Text,null);
.
. Execute the command
.
ida.SelectCommand=helper.CreateCommand(conn,"select * from B",CommandType.Text,null);
.
. Execute the new command
.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hai guys,
is it possible to serialize a hashtable that contains objects of a class and that particular class contains a hashtable? If it is possible, Please give me your valueble advice
Regards,
Rathish P S
|
|
|
|
|
The HashTable class is itsself serializable. If it only contains object which are either implementing ISerializable or having the Serializable attribute there no reason why you should not be able to serialize it.
Just try marking all classes within the HashTable (and also references other classes) with the Serializable attribute and then serialize it:
<br />
System.Runtime.Serialization.Formatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
f.Serialize(myStream, myHashTable);<br />
Thats basically all you HAVE to do. There are many problems which can arise, especially when it comes to efficiency. You are free to ask again if you reach such a point
|
|
|
|
|
Ok im so confussed why this happens, but it does...everytime.
In my custom list control, when i add items to the control, the scrollbars adjust.
Now all this works like clockwork until i start adding items to the control from a thread...at which time the items get added just fine to the collection, but after a few milliseconds of adding i see the scrollbar thumb shrink and shrink and then the whole scrollbar literally DIAPPEARS!
I accessed that controls properties with propertygrid when the problem happens and it reports that the control is visible and right where it should be with a viewable size. I really don't know what to do...i think trying to update a scrollbars largechange and maximum from asynch requests to add causes it to bug out...
If theirs no fix for this im gonna have to make my own scrollbar...something that can stand up to the stress.
|
|
|
|
|
Accessing windows controls from threads other than the one which instanciated them has often weird results.
Therefor try to invoke the adding of items, so it gets executed on the thread that instantiated the control. See the docs for the Control.Invoke[^] method for some more infos.
www.troschuetz.de
|
|
|
|
|
Can you show me some example of what the function i pass to my scrollbar's.Invoke looks like. Like parameters and return type... Just never used invoke before and ironically i saw an article on threading on msdn the other day that was just what i needed, but it's not in my browsers history!
|
|
|
|
|
wait nvm, i found what i needed in someone's blog.
Link provided if anyone else needs to know this stuff http://blogs.bartdesmet.net/bart/archive/2004/11/07/462.aspx
|
|
|
|
|
can anyone teach me how to connect to a email server to send emails through my email name??
|
|
|
|
|
|
I perhaps can sympathise that this wasn't as simple to find.
When I first tried to use it I found it hard to know what I was looking for, so here's a sort of sample class that might help you out.
public class EmailSender
{
MailMessage mailMsg;
public EmailSender(string to)
{
mailMsg = new MailMessage();
mailMsg.From = "Me@frommySMTP.com";
mailMsg.To = to;
SmtpMail.SmtpServer = "10.10.10.XXX";
}
public void sendMessage(string subject, string body)
{
mailMsg.Subject = subject;
mailMsg.Body = body;
SmtpMail.Send(mailMsg );
}
}
Even if the class doesn't serve your purpose the code should give you an idea.
I think the include is like:
using System.Web.Mail;
You will have to reference that yourself.
Hope this helps,
Jim
P.S. For exchange servers your going to need to look up MAPI.
|
|
|
|
|
|
hey.... i have something very weird...
using System.Web.Mail; is the correct way of doin this....but when i put it into my references, it does not work and i get a build error.... what does that mean??
|
|
|
|
|
Hi,
How to create a ColumnHeader with 2 header lines for a listView?
eg: | country1 | country2 |............|
|------------|-----------------|------------|
|city1|city2 |city3|city4|city5|............|
Thanks
chesslin
|
|
|
|
|
Does anybody know if you can create an C# class object from vba pasing parameters through the constructor. if not, then the constructor can only be one for each class and no parameters? I did overload a function in c # and vba did not recognise this. Anybody with knowledge here would be greatly appreciated,
Regards
Mit
notsnoj
|
|
|
|
|
VBA is not aware of constructors. In fact, COM itself - VBA being an OLE automation client which is built on COM - is not aware of constructors.
COM describes calling methods on objects, not how the objects are obtained. A common workaround for a complete lack of constructs is an initialization method of sorts, in which you'd pass parameters that you'd normally pass to a constructor.
To expose a "C# class" (BTW, all C# codes - like other managed languages - compiles to IL so it's all basically the same, sans compiler optimizations and language features) to COM you must actually have a public constructor (either inheritted or defined). If not, you can expect a COM error to be raised (or a managed exception to be thrown, depending on the circumstances).
You should also follow COM guidelines, like attributing all classes and interfaces with a unique GuidAttribute value and not using auto-generated class interfaces, but explicitly defining your own. Never change a published interface, either, but derive from it and implement that as the first interface for your class (which the CLR treats as the class interface).
Read Exposing .NET Framework Components to COM[^] and Design Considerations for Interopation[^] in the .NET Framework SDK for more information.
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]
|
|
|
|
|
Thankyou very much for this information.
Regards
Mit
notsnoj
|
|
|
|
|
I need to get icons for special folders, such as Desktop, My Computer, My Documents, etc.
I've been able to use the SHFILEINFO API to get icons for drives, regular folders and, of course, files... however, I can't seem to figure out how to get the icons for the 'special folders'
I've been told to use the Environment namespace, but I don't see how that will help me. Apparantly I need to get and pass a pidl for the special folder to SHFILEINFO, but... again, I'm not sure how to do either.
I'm relatively new to C#, so I could be entirely mistaken about how I'm supposed to get these icons. If there are any other ways I can do this, do let me know.
Any help would be greatly appreciated!
|
|
|
|
|
If you read the linked documentation in the Platform SDK PIDLs are discussed in great detail. The easiest way to get these is to navigate from the desktop to the shell namespace and/or folder to get the PIDL. You can do this easily by creating an RCW (runtime-callable wrapper) using either tlbimp.exe or adding a reference to your project using the COM tab for the "Microsoft Shell Controls and Automation" typelib.
See the Shell Objects for Scripting[^] for documentation. How you use the classes is essentially the same (though not 100%) because the automation objects provide functionality to automation clients like Windows Script, VB6, and RCWs.
It would be easier and require less dependency to P/Invoke SHParseDisplayName , but you really must read the documentation to understand what you're passing, since it requires that you also pass an IBindCtx (the interface is declared as System.Runtime.InteropServices.UCOMIBindCtx , but you must still get an instances by P/Invoking CreateBindCtx ).
Experience with shell programming and COM is extremely helpful, and there's a lot of information in the Platform SDK to give you hints on how to do this. Understanding COM interop is also important.
If you have specific questions, please ask. Do first read the documentation, however, since you need to understand the native code in order to know what and how to P/Invoke it correctly, like redefining your SHGetFileInfo signature to access either a string marshaled correct (see the Marshal class for help) or a PIDL, which is an ITEMIDLIST structure which you may or may not have to define depending on how you use it (you could just declare it as an IntPtr if you don't need to parse it yourself).
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]
|
|
|
|
|
If thread A raises an event E and thread B has the handler, is there any different to use E(...) and E.BeginInvoke(...)? They are both asynchronous anyway, right?
|
|
|
|
|
No, they are not both asynchronous. If you simply invoke an event (a MulticastDelegate ) it is fired in the context of the calling (invoking) thread. If you use BeginInvoke a new thread from the thread pool is grabbed and used to execute the handler. If you want to execute the handler on the thread that instantiated the class (very important for Control classes in Windows Forms), then the object implementing the handler must implement ISynchronizeInvoke (or similar functionality - that that would be up to you) and you call its ISynchronizeInvoke.Invoke implementation.
Read Handling and Raising Events[^] and Threading[^] in the .NET Framework SDK for more information. You should also read the documentation[^] for the Control.Invoke method if you're dealing with threading in a Windows Forms application.
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 debugged the code step by step. What confused me is why when I invoked an event from a thread (NOT using begininvoke), the code immediately returned and continued to execute rest of code in the calling thread? Isn't it supposed to run the delegate func first and then return?
|
|
|
|
|
Did you have a break point in your event handler? If you're just stepping into code, IIRC, it won't trace into the delegates. Using Debug.WriteLine is another useful way to debug such issues and won't be compiled into release builds (so you don't have to remove it or use pre-proc conditions when compiling for release builds).
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 used Debug.WriteLine. And that revealed the event.invoke is synchronous call. You are absolutely right. I guess step-by-step is not that trustworthy when dealing with events.
Thank you!
|
|
|
|
|
Hi,
I am trying to calling Visual C++ dll function in C#.
This is function I am trying to call from dll.
float CMD_RD(int port, int address, int *err_type, int *err_attr)
Here is my code.
public class OmegaBusWrap
{
[DllImport("C:\\work\\Eco-now\\Code\\OmegaBus\\OmegaLib\\cmd_dll.DLL",
EntryPoint="CMD_RD", SetLastError=true,
CharSet=CharSet.Auto, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern float CMD_RD(int port, int ddress,IntPtr
err_type, IntPtr err_attr);
}
Here I am calling this function in my code
IntPtr err_type = new IntPtr(0);
IntPtr err_att = new IntPtr(0);
float fvalue;
try
{
fvalue = OmegaBusWrap.CMD_RD(m_PortNo,1,err_type,err_att);
}
catch(Exception e)
{
Debug.WriteLine(e.ToString());
}
I got exception this exception
System.NullReferenceException: Object reference not set to an instance of an object.
at OmegaBusSerial.OmegaBusWrap.CMD_RD(Int32 port, Int32 address, IntPtr err_type, IntPtr err_attr)
What I am doing wrong, How can I solve this problem.
Thanks.
|
|
|
|
|