|
Yes. But still why you are assigning value to variable index if you are not using it ?
|
|
|
|
|
public int DropDownListSelecttedIndex
{
get
{
return DropDownList1.SelectedIndex;
}
set
{
DropDownListSelecttedIndex = value;
}
}
Is it right now?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
I want to add child nodes in tree veiw
how can i do it.
foreach (DataRow row in tbs.Rows)
{
treeVu1.Nodes.Add(row["TABLE_NAME"].ToString());
foreach (DataRow row1 in clmns.Rows)
{
TreeNode tnode = new TreeNode("COLUMN_NAME");
//here i want to add columns names as child
}
}
regards,
chanzeb chaudhary
|
|
|
|
|
you need to get the particular TreeNode object to which you wanna add the child to and then use the Add function like that. how to get that Node programatically is up to u.
Hope that helps
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
hi friends,
i did lot of R&D on this but finally i was stopped here ........and i am unable to do this ...please provide the solution for this ..
i am passing the parameters from webapplication(asp.net to c#)
i wrote the code in asp.net is like this
System.Diagnostics.ProcessStartInfo startInfo;
Process p = new Process();
p.StartInfo.Arguments = "new" ;///this line is for passing the parameters to that exe)
startInfo = new System.Diagnostics.ProcessStartInfo(@"Mainform.exe");
how can cal the above parameter ("new") in the exe(c#)
Ramesh
|
|
|
|
|
Hello,
I dont' know if I understand your question.
But if you want to know where you get your argument in your C# project.
It is the Main Entry Point
public static void Main(string [] Args)
{
if (Args.Length > 0)
{
string value1 = Args[0];
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
The following code is being executed in a highly threaded environment.
1. Why does the Debug.Assert statement sometimes fail?
2. What can be done to stop this from occurring?
public class Warehouse
{
private int stockCount = 0;
public void DecrementStock ()
{
if ( stockCount > 0 )
stockCount--;
Debug.Assert ( stockCount >= 0 )
}
public void IncrementStock()
{
stockCount ++;
}
}
|
|
|
|
|
If you're running this code in a threaded environment you are running into problems because it's not thread safe. The Debug.Assert call itself isn't threadsafe and neither are the DecrementStock and IncrementStock methods. The most likely explanation is that you have multiple threads manipulating the stockCount variable at the same time which is giving unpredictable behavior.
There are a lot of different ways to protect against this, from using the lock keyword to using InterlockExchangeCompare . The easiest is probably the lock syntax, which would look something like this:
public class Warehouse
{
private object syncRoot = new object();
private int stockCount = 0;
public void DecrementStock ()
{
lock(syncRoot)
{
if(stockCount > 0)
{
stockCount--;
}
Debug.Assert(stockCount >= 0);
}
}
public void IncrementStock()
{
lock(syncRoot)
{
stockCount++;
}
}
} Also, in the future, please use the <pre> tags for code blocks to preserve the formatting.
|
|
|
|
|
Friends,
Is there a way to backup database using c#? What I mean is that,
in a form, there is database name, login and password. When I click backup button, it will create backup in sql server management.
Example: CODEPR(databasename) then click backup button it will named as CODEPR_backup.
Any help or links much appreciated.
Thanks,
C#Coudou
******************************
I just want to
know everything
|
|
|
|
|
Hi,
There is a system stored procedure for database backup functionality. (I cannot remember the sp's name at the moment).
So you can execute that sp from your C# code.
Hope this helps to you.
http://msdn2.microsoft.com/en-us/library/ms188409.aspx
Regards!
jayasshc
|
|
|
|
|
Backup/Restore Programatically[^]
I think you need to add an SP with BACKUP functionality and execute that
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
|
Do you have a question? What was the point of your post?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
There's a link in my thread, read it at it's location and answer here if you can. Thanks.
|
|
|
|
|
Example:
....<br />
Thread a = new Thread(method1);<br />
a.Start();<br />
....<br />
....<br />
void method1() {<br />
textBox1.Text = "Hello";<br />
}
if i execute that code, they give me an InvalidOperationException error (access to textbox1 from another process)
i try to call that method using an delegate, but not works
another way is add this code:
CheckForIllegalCrossThreadCalls = false;
but i don't need to deactivated that
how i can fixed?
|
|
|
|
|
you can access a Control only from the thread that created it, normally the main thread.
Read up on Control.InvokeRequired and Control.Invoke()
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
need some tutorial or example please (to understand)
|
|
|
|
|
MSDN, Google and CodeProject are full of examples: almost every app that uses extra threads
needs it!
Here is an example in VB.NET[^], the last code snippet shows the principle.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Y readed and works fine
my C# Code:
public delegate void updatevalores(string dato);<br />
private void actualizarv(string datos) {<br />
if (this.InvokeRequired)<br />
{<br />
this.Invoke(new updatevalores(actualizarv),new object[]{dato});<br />
return;<br />
}<br />
listBox1.Items.Add(dato.ToString());<br />
}
Thanks for all
|
|
|
|
|
I am trying to pass a structure to unmanaged C and the unmangaed C returns an error because it thinks a value within the struture is set to a different value then the c# has set it to prior to passing it to the unmanaged c. I dont't have access to the C code.
[StructLayout(LayoutKind.Sequential)]<br />
public struct PASSTHRU_MSG<br />
{<br />
public UInt32? ProtocolID;<br />
public UInt32? RxStatus;<br />
public UInt32? TxFlags;<br />
public UInt32? Timestamp;<br />
public UInt32? DataSize;<br />
public UInt32? ExtraDataIndex;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4128)] <br />
public byte[] Data;<br />
}<br />
<br />
[DllImport("CARDA432.DLL", EntryPoint = "PassThruStartMsgFilter", ExactSpelling =true)]<br />
public static extern UInt32 PassThruStartMsgFilter(UInt32 ChannelID, UInt32 FilterType, ref PASSTHRU_MSG pMaskMsg, ref PASSTHRU_MSG pPatternMsg, ref PASSTHRU_MSG pFlowControlMsg,ref UInt32 pMsgID);<br />
<br />
MaskMsg.Data = new byte[4128];<br />
MaskMsg.ProtocolID = 5;<br />
MaskMsg.DataSize = 4;<br />
MaskMsg.Data[0] = 0xff;<br />
MaskMsg.Data[1] = 0xff;<br />
MaskMsg.Data[2] = 0xff;<br />
MaskMsg.Data[3] = 0xff;<br />
PatternMsg.Data = new byte[4128];<br />
PatternMsg.ProtocolID = 5;<br />
PatternMsg.DataSize = 4;<br />
PatternMsg.Data[0] = 0x00;<br />
PatternMsg.Data[1] = 0x00;<br />
PatternMsg.Data[2] = 0x07;<br />
PatternMsg.Data[3] = 0xE8;<br />
<br />
FlowMsg.Data = new byte[4128];<br />
FlowMsg.ProtocolID = 5;<br />
FlowMsg.TxFlags = 0;<br />
FlowMsg.DataSize = 0x04;<br />
FlowMsg.Data[0] = 0x00;<br />
FlowMsg.Data[1] = 0x00;<br />
FlowMsg.Data[2] = 0x07;<br />
FlowMsg.Data[3] = 0xE8;<br />
<br />
if ((status = PassThruStartMsgFilter(ChannelID, FLOW_CONTROL_FILTER, ref MaskMsg, ref PatternMsg, ref FlowMsg, ref FilterID)) != STATUS_NOERROR)<br />
{<br />
status = PassThruGetLastError(serror);<br />
MessageBox.Show(serror.ToString());<br />
}<br />
the function returns an error stating that the MaskMsg.ProtocolID = 1 (the code is expecting 5 as set by the c# code) and I can't figure out why? There must be an issue with the memory getting overwritten or the "pointer" not being referenced properly.
|
|
|
|
|
It doesn't matter what I set the ProtocolID to the code always errors out with ProtocolID =1.
The original C-code
typedef struct<br />
{<br />
unsigned long ProtocolID;<br />
unsigned long RxStatus;<br />
unsigned long TxFlags;<br />
unsigned long Timestamp;<br />
unsigned long DataSize;<br />
unsigned long ExtraDataIndex;<br />
unsigned char Data[4128];<br />
} PASSTHRU_MSG;<br />
<br />
long PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pMsgID); <br />
<br />
<br />
-- modified at 19:44 Thursday 11th October, 2007
|
|
|
|
|
I have never seen a nullable type being passed to unmanaged code, and I don't expect
it to work like that, so first thing to do is drop all the question marks.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
It doesn't seem to matter if the other variables are null or defined. And other api calls require the PASSTHRU_MSG to be null.
I have had the questions marks there and not and still fail with the same error.
Thanks.
|
|
|
|
|
Hi,
an Uint32 is a value type, taking 4 bytes of memory inside the struct.
an Uint32? is a reference type, taking a 4B (or 8B on Win64) pointer inside the struct
and an object on the heap, quite different from what your C code expects.
So, yes removing the questions marks is a necessary step towards a solution.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Fair enough. I'll give it another shot.
|
|
|
|