|
Hi,
save all the five string in a single string with comma(,) separated and split that particular string
by comma(,) when insertion performed in database.
Good luck
|
|
|
|
|
There are two ways you can do this job:
1. Insert strings into a Datatable and then add it to the Dataset.
2. if you want to directly add the strings, each string individually be in a diffrent table(5 tables) or merge all the 5 strings and insert into the dataset.
Hope this answers your question.
Cheers
Amit
|
|
|
|
|
I've got three timers in front of me:
1) Forms.Timer
2) System.Timer
3) Threading.Timer
Which one's callback does not block the current thread when the timer event fired?
Best,
Jun
|
|
|
|
|
I doubt any timer in any language on any OS that supports threads would block the "current thread" when it fires.
|
|
|
|
|
Why not try reading the documentation on each of those first??
|
|
|
|
|
I read those docs. They are not clear, at least to me. I thought I knew but started doubting myself at work.
Best,
Jun
|
|
|
|
|
You could have tested this quite easily and done it in about 5 minutes.
Setup each time and setup a handler for the event/callback for each timer. In the handler, you put one line of code:
Debug.WriteLine(@"Current Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
Put the same line of code at the top of the app and you'd know if the thread is different by the ID numbers.
|
|
|
|
|
The System.Windows.Forms.Timer is the only one that is called on the UI thread if that's what you mean.
|
|
|
|
|
If you want your code to run in a separate thread, then use a BackgroundWorker , because it is very easy to use. I believe System.Timers.Timer and System.Threading.Timer also run their target code in a separate thread. System.Forms.Timer runs in the UI thread.
|
|
|
|
|
|
So far this appears to have stumped a lot of folks, including myself.
The function in Delphi works correctly, the function in C# is crashing with managed/unmanaged errors.
using a delphi.pas generated mrdsio.dll file, the Receive(Adr,Len) is sent on to the mrdsio.dll for processing (mrdsio.dll sends and retrieves data to an mcu epprom memory bank with Adr as Address and Len as Length)
The Tdata (single dimension byte array) is returned from the mrdsio.dll and processed as Data.
Again, Delphi code works, C# fails.
any clues?
original Delphi Code:
type<br />
TData = array [0..255] of byte;<br />
<br />
function Receive(Adr, Len: integer): TData; stdcall; external 'mrdsio.dll';<br />
<br />
procedure TForm1.Button5Click(Sender: TObject);<br />
var Data: TData;<br />
i: integer;<br />
s: string;<br />
begin<br />
if not (CheckBox1.Checked) then<br />
begin StatusBar1.SimpleText:='Bidirectional operation not allowed'; exit; end;<br />
for i:=0 to 255 do Data[i]:=0;<br />
Data:=Receive($02,8);<br />
if (Data[1]=0) then<br />
begin StatusBar1.SimpleText:='Failed, check Connection'; exit; end;<br />
s:='';<br />
for i:=1 to 8 do<br />
s:=s+Chr(Data[i+1]);<br />
Edit1.Text:=s;<br />
end;
Converted C# code;
[DllImport("mrdsio.dll", EntryPoint="Receive", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]<br />
public static extern byte[] Receive(int Adr,int Len);<br />
<br />
private void btnRX_Click(object sender, EventArgs e)<br />
{<br />
byte[] Data = new byte[256];<br />
int i;<br />
string s;<br />
int Adr = 0x02;<br />
int Len = 8;<br />
for (i = 0; i <= 255; i++) Data[i] = 0;<br />
Data = DLL.Receive(Adr, Len);<br />
s = " ";<br />
for (i = 1; i <= 8; i++)<br />
s = s + Data[i + 1].ToString();<br />
txtBox1.Text = s;<br />
}<br />
|
|
|
|
|
Aurbo7 wrote: crashing with managed/unmanaged errors.
Unless you show the exact text of these errors any suggestions will be pure guesswork.
The best things in life are not things.
|
|
|
|
|
MarshalDirectiveException was unhandled<br />
<br />
Cannot marshal 'return value' Invalid managed/unmanaged type combination.
|
|
|
|
|
Your unmanaged code returns a pointer to an array, but your managed code has not been told how to marshall the data. I'm not an expert in this interface but you need to add some more attributes to tell the marshalling code that a pointer is being passed back. You can find more information here[^].
The best things in life are not things.
|
|
|
|
|
If Richard is correct and it's returning a pointer then you may need to copy the data at the pointer to a managed byte array.
byte[] data = new byte[256];
IntPtr result = DLL.Receive(Adr, Len);
Marshal.Copy(result, data, 0, 256);
[DllImport("mrdsio.dll", EntryPoint="Receive", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern IntPtr Receive(int Adr,int Len);
|
|
|
|
|
Dave,
your version offers up a different error,
'AcessViolationException was unhandled'
Attempted to read or write protected memory.
|
|
|
|
|
OK, I'm a little confused as I'm not familiar with Delphi.
Does the function return a single byte, a pointer or a byte array? That it loops 256 times indicates it may be just a byte that is returned which needs to be added to a separate byte array?
|
|
|
|
|
Tdata returns an entire single dimension byte array.
Adr is the memory address, in this instance eeprom memory address: 0x02
Len is the length of the data bytes[8]
256 was just the standard number for an array declaration, In all reality and practicality
byte[] Data = new byte[256];
could just be
byte[] Data = new byte[8]
The byte[8] is then run through the for i=.... loop to convert the array from bytes to string.
|
|
|
|
|
This assumes that the result actually is 256 bytes. I suspect that
Marshal.Copy(result, data, 0, len);
might actually be what is wanted here.
The original code seems poorly written, Data is initialised and then assigned to, making the initialisation step pointless.
|
|
|
|
|
The error is on 'DLL.Receive' I assume?
What is the actual declaration of the target function in C? I suspect that Delphi is marshalling the result type automatically in some way and C# is not doing the same thing, and the result type isn't actually byte[] (it is probably byte*). Marshalling pointer types requires a bit more work in .Net.
|
|
|
|
|
Correct, Error occurs at Receive(Adr,Len)
The Delphi version as posted in the original entry, works fine with the Delphi example.exe calling the Delphi.dll. There is a Send(Data[],Len) routine as well that works fine in both Delphi and its converted C# version.
I have not explored the byte* route yet, perhaps it may offer a solution.
|
|
|
|
|
I'm having procedure with following fields e.g.(Previous.Balance, Debit, Credit )
Now in crystal reports. I want report structure like an account statement e.g. bank statement.
Description Dr Cr. Balance
Opening.. prevBalance
transaction 1 10000 prevBalance+Dr-Cr
transaction 2 5000 upperBalance+Dr-Cr
transaction 3 5000 upperBalance+Dr-Cr
How to achieve this type of running total in crystal reports in VS2010.
Regards.
Asif Rehman
|
|
|
|
|
Hello Everybody,
I want to create a List for Parent Child Information. So I want to know that what is the best Object for Store Information of Parent Child.
I am confused with :
Arraylist, IList,List,Distionery or
else in your mind.
If you have any example then your most welcome to share your knoledge.
Thanks
If you can think then I Can.
|
|
|
|
|
A List .
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hello John,
Thanks for your suggession. Can u please help me How Can i Create a class that contain the information of Parant and Childs.
Thanks
If you can think then I Can.
|
|
|
|