|
Hello,
I have the statement as indicated below, after I find the appropriate the row in my dataset, I want to duplicate this whole row, but change the values of 2 row element. How can I do that?
foreach (DataRow row in dataset.Tables["Versions"].Rows) {
if ((row["ProjectID"].ToString() == currProjID) && (row
["VersionNumber"].ToString() == currentVersion)) {
string verID = row["VersionID"].ToString();
if (row["IsProjectSetupComplete"].Equals(true)) {
WHAT GOES IN HERE?
}
}
}
Thank you.
|
|
|
|
|
row["col"] = new value;
dataset.Tables["Versions"].Rows.Add(row.ItemArray);
|
|
|
|
|
Im unable to find an error with this supposedly incorrect snippet that appeared in an aptitude test..please help me ASAP!!
i'd be very greatful...Thanx!
class Singleton
{
public static Singleton Instance() {
if (_instance == null)
_instance = new Singleton();
return _instance;
}
protected Singleton() {}
private static Singleton _instance = null;
}
Rohit(Mumbai)
|
|
|
|
|
I think the only thing I can see that is wrong is that the constructor is protected. Therefore if a second class derived from this class then it would be able to call the base() call from it's constructor. The class itself would need to be set as FINAL so that no derived classes could be created.
Anybody else spot anything else????
|
|
|
|
|
The singleton code is not thread safe. If it is guaranteed to run in a single threaded fashion, then I don't see any problem. But if two threads happen to call Instance() at the same time, there is a chance that there would be two separate Singleton objects, which defeats the very purpose of having a singleton.
The right way to do it is to protect the Instance() method with a lock. Something like
private static object syncObject = new object();
public static Singleton Instance()
{
lock(syncObject)
{
if (_instance == null)
_instance = new Singleton();
return _instance;
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Does anyone here know where to find and how to use Microsoft's timezone control (the one where you set your time zone from Control Panel/Date & Time; shows a flat projection of the globe)?
Ideally, I'd like something like .NET's fontDialog() or colorDialog().
|
|
|
|
|
If you don't care about the return value, you can just shell to
c:\winnt\system32\timedate.cpl
to pop up the date/time control panel applet.
Sean
|
|
|
|
|
Thank you, Sean. That is very helpful, I'll investigate timedate.cpl. I do need to get the timezone the user selects, without actually changing the PC's settings. This is so a new timezone can be selected for a "World Clock" application.
Thanks again for your help.
John
|
|
|
|
|
Ahhh, sorry, I don't think this will do what you want then. There are no command line parameters passable to the control panel applet (that I can find), and no way to retrieve the value once the user has set it by just shelling to the applet.
I don't think the map selection functionality is exposed as an ActiveX control either.
Sorry 'bout that.
Sean
|
|
|
|
|
I want to dynamically load DLLs (created from VB) and instantiate a class with a particular name, like "ProcessClass".
I am able to load the DLL and confirm there is a class by that name BUT I can't seem to create it or call methods to this newly created instance. I have the following code:
public class Script
{
[DllImport("oleaut32", CharSet=CharSet.Unicode)]
private extern static void LoadTypeLib(string dllFilePath, out UCOMITypeLib typeLibrary);
UCOMITypeLib typeLibrary;
LoadTypeLib(dllName, out typeLibrary);
for (int i = 0; i < typeLibrary.GetTypeInfoCount(); i++)
{
typeLibrary.GetDocumentation(i, out typeName, out typeDocumentation, out typeHelpContext, out typeHelpFile);
if (typeName == "ProcessClass")
{
UCOMITypeInfo typeInformation;
object classInstance;
typeLibrary.GetTypeInfo(i, out typeInformation);
typeInformation.CreateInstance(null, ref guidIUnknown, out classInstance);
MethodInfo method = classType.GetMethod("DoSomething", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public );
method.Invoke(classInstance, new object[0]);
}
}
}
Am I going down the wrong road? The class seems to be created without exception, but the created instance doesn't seem to be bound properly as I don't see any of the methods I'm looking for when I loop through!!
-Ray
|
|
|
|
|
I'm trying to inherit a form an initially am able to do so, however when I build the project I loose the design view for the new inherited form. In the design view tab it says there was an exception 'Request for the permission of type System.Security.Permissions.SecurityPermission failed'
The project still builds and no error is thrown when the form is instantiated at run time. Any ideas where I might be going wrong?
|
|
|
|
|
A lot of my controls don't show nicely in the design view, and I had one that broke the build, although the code would have been fine if it built and ran. I don't bother to fix them, I'd rather have the code look the way I want, than hack for the sake of a view I almost never use.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is there an artical anywhere describing how to hack around such problems though? I've got a project with a control that generates a null reference exception in the designer with any form that uses it. At long as it's not exceptionally bad how the code looks isn't a major concern since the control's just slurped out of the dll, while the forms involved are being actively modified.
|
|
|
|
|
I found that the problem is that the visual designer tries to render the form, so look through your constructor and any events such as OnPaint, and imagine they are being called without any properties being set. I fixed the one that broke the build by moving code from the init event to another method, and wrapping it in code that guarded against it being called by checking first that everything was in the correct state for it to occur.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I was wondering if any one had some ideas or good places to look for help on a alphnumeric counter.
The count I want to put into place is one that starts at 'AAA000' and continues with 'AAA001' and so on. So when the number hits 999, the next record will have a id of 'AAB000'
Please let me know if you have any ideas or a good site to visit.
Thanks.
|
|
|
|
|
Wow - you asked this in the SQL forum, so I thought you wanted it to be in T-SQL. A counter like this is easy - just define the numeric portion and the letter portion. Then when the numbers hit 1000, roll over and increment a letter.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to post a string of xml to another site and I've set up a test script on my own machine to recieve and parse the xml and return a value. When I run that page by itself and feed it some xml, it works fine. But, when I try to call it with the webrequest object, I get an internal server error. Can anyone see what I'm doing wrong here? I've never used this class before so I'm not really sure if I'm doing everything I'm supposed to. Thanks. Oh, and it errors on the line that says WebResponse myWebResponse = myRequest.GetResponse();
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/test.asp");
myRequest.Method="POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
ASCIIEncoding encoder = new ASCIIEncoding();
// Convert the string into a byte array.
byte[] xmlBytes = encoder.GetBytes("xmlData="+xDoc.InnerXml);
myRequest.ContentLength = xmlBytes.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(xmlBytes,0,xmlBytes.Length);
newStream.Close();
// Return the response.
WebResponse myWebResponse = myRequest.GetResponse();
// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( ReceiveStream, encode );
response = readStream.ReadToEnd();
readStream.Close(); readStream = null;
myWebResponse.Close();
|
|
|
|
|
nevermind. after playing with some other debugging code, I found that the problem ended up being in the page that receives the xml and that it's not receiving it correctly.
|
|
|
|
|
hi to all,
how can i send sql server message to my c# application.
exemple :
in a stored procedure i use the RaiseError keyword with a specific number and description.
all i want to do is to get these two informations in my c# application.
does any know how ?
best regards and thanks in advance
fady
|
|
|
|
|
Use a try/catch and handle the SqlException?
|
|
|
|
|
Hello there.
I was wondering if anyone know if there exist a way to iterate through your named ranges? All I seem to find is:
(Excel.Range)App.get_Range("test", Type.Missing);
Where "test" would be a named range I've specified before manually. I would love to find some easy method like :foreach(NamedRange in ..) etc. So it iterates through all my previously defined names, for example test, test1, test2 etc.
I'm also having large troubles actually getting the name "test" out of anything. rng.Name only gives the address to the range.
I would like this because I want to iterate through all named ranges, sending the name of the range to a webservice and depending on what I would get back I would set a value. Right now I will need to code every specifik instance of them and that will make it harder to add things.
Thanks Christer.
|
|
|
|
|
I'm going insane trying to fix this exception.
I'm building a Browser Helper Object that makes uses of a library that uses GDK-sharp for image handling. GDK-sharp then uses glib-sharp, which then loads libglib-2.0-0.dll so that it can use some of its marshalling code as an extern.
At runtime I get a DllNotFoundException at the point where the DLL is imported into glib-sharp. It claims it can't find libglib-2.0-0.dll. But that DLL is in fact in my path. If I run Filemon it shows the iexplore.exe process successfully loading libglib-2.0-0.dll and its dependencies. Dependency Walker claims I have no missing dependent DLLs. I can't see what could be going wrong here.
One thing might be a lead. When I run it connected to the debugger I get the following error message:
'iexplore.exe': Loaded 'C:\GTK\2.6\bin\libglib-2.0-0.dll', No symbols loaded.
'iexplore.exe': Loaded 'C:\WINDOWS\system32\iconv.dll', No symbols loaded.
First-chance exception at 0x7c964ed1 in iexplore.exe: 0xC0000139: Entry Point Not Found.
I've tried uninstalling and reinstall glib and gtk, but that didn't solve my problem.
Help!
Thanks in advance,
Chris Metcalf
|
|
|
|
|
Hello,
i have a problem with Events ....
i have to use C# and send events to a COM interface
i would like to activate this events by this C#.dll or also through the same COM interface
the COM comunications works but it dosn't fire an event ...
for the test i use a client written in VB6
i would be nice when you can me give any help
(i working with .NET 2003 / VS6.0 on a XPpro)
i have the feeling that ACCOMEvt(src, DateTime.UtcNow); dosn't work rigth ...
here my Code for the server:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ACEvt
{
public delegate void ACDelegate(string Source, DateTime TimeStamp);
[Guid("AC4C1820-04B6-4988-928F-FD858B95C880")]
public interface ACCOMInterface
{
[DispId(1)]
DateTime getACTimestamp();
[DispId(2)]
void ActivateACCOMEvt(string source);
}
[Guid("ACC976E0-C208-4740-AC42-41212D3C34F0"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ACCOMEvents
{
void ACCOMEvt(string src, DateTime TimeStamp);
}
[Guid("AC5E5FB2-219D-4ee7-AB27-E4DBED8E123E"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ACCOMEvents))]
public class ACCOM : ACCOMInterface
{
public event ACDelegate ACCOMEvt;
public ACCOM()
{
//must be empty !!!!
}
public DateTime getACTimestamp()
{
MessageBox.Show("getACTimestamp");
return DateTime.UtcNow;
}
public void ActivateACCOMEvt(string src)
{
MessageBox.Show("ActivateACCOMEvt");
ACCOMEvt(src, DateTime.UtcNow);
}
}
}
and the VB6 Client without the form:
Option Explicit
Dim WithEvents bmw As AC_Evt.ACCOM
Private Sub Form_Load()
Set bmw = New AC_Evt.ACCOM
End Sub
Private Sub TimeStampBtn_Click()
EvtLst.AddItem bmw.getACTimestamp(), 0
End Sub
Private Sub ActEvtBtn_Click()
bmw.ActivateACCOMEvt ("ActEvtBtn")
End Sub
Private Sub bmw_ACCOM_Evt(ByVal src As String, ByVal Timestamp As Date)
EvtLst.AddItem ">" & src & " " & Timestamp, 0
End Sub
skai007
|
|
|
|
|
Hi,
While reading through many informative articles regarding controls, transparency and alike on C#.
One question remained un-answered every time. How to implement real transparency rather than a fake one.
What is implemented in all the articles is fake, in sense they paint the background of the form, rather than the other controls that are placed underneath the control having transparency.
I myself is quite locked into same situation, and still haven't found no solution.
Compositing mode also didn't help.
Any ideas how to procede and have real transparency enabled.
Thanks.
Jaswinder Singh Kohli
|
|
|
|
|
true transparency is only supported by top level windows (forms)
using "LayeredWindows" api
//Roger
|
|
|
|