|
Hi all!
I have the following situation - three tables in the db :
- um_users (id, name)
- um_roles (id, description)
- um_user_roles (user_id, role_id)
I load into a data set two datatables : the "users" one, and another one build on the other two, like this :
_cmd = new OracleCommand("select * from um_users", _conn);
_odaUsers = new OracleDataAdapter();
_usersDataSet = new DataSet("um_users");
_odaUsers.SelectCommand = _cmd;
_odaUsers.Fill(_usersDataSet, "um_users");
_cmd = new OracleCommand("select u.user_id, r.role_id, r.role_name, r.descr " +
"from um_users u " +
"inner join um_user_roles ur on u.user_id = ur.user_id " +
"inner join um_roles r on ur.role_id = r.role_id ", _conn);
_odaUsers.SelectCommand = _cmd;
_odaUsers.Fill(_usersDataSet, "um_user_roles");
_usersDataSet.Relations.Add("users_uur", _usersDataSet.Tables[0].Columns["USER_ID"], _usersDataSet.Tables[1].Columns["user_id"]);
This snippet also adds a relation between the two.
I display them in a ultrawingrid from infragistics, and I'm able to edit them. Saving the modifications for the first table worked with no problem,but since the second one is more like a view, i have no ideea how should i proceed. should i build an insert command or how ?
Thanks!
|
|
|
|
|
I have a code block like this:
{
m_ReaderName = m_Reader.ReaderName;
m_Reader = new ProprietaryReader(ReaderName);
retVal = (int) Status.Success;
}
Q: how to cache the reader name using the input param??
Any help are deeply appreciated..
|
|
|
|
|
hello
How to convert any object to byte[] without marking it Serializable or DataContract?
Of course this would work but you'd need to mark myObj class Serializable (I'm lazy dont want handcode serializable for big classes sorry)
using (System.IO.MemoryStream returnStm = new System.IO.MemoryStream())
{
BinaryFormatter ftm = new BinaryFormatter();
ftm.Serialize(returnStm , myObj);
return returnStm .ToArray(); // this would return byte[]
}
Anyone who can tell me how I can commit such crime?
Thank you
|
|
|
|
|
Hi, I do this and it works for me.
public byte[] RawSerialize(object item, Type anyType)
{
int structSize = Marshal.SizeOf(item);
IntPtr ptr = Marshal.AllocHGlobal(structSize);
Marshal.StructureToPtr(item, ptr, true);
byte[] bff = new byte[structSize];
Marshal.Copy(ptr, bff, 0, structSize);
Marshal.FreeHGlobal(ptr);
return bff;
}
|
|
|
|
|
Many thanks I don't have time test it now but already feel my knowledge increase
|
|
|
|
|
Hello Gonzalo
Do you have the code for reverse process as well please please please?
|
|
|
|
|
public static object RawDeserialize(byte[] rawdatas, Type anytype)
{
int rawsize = Marshal.SizeOf(anytype);
if (rawsize != rawdatas.Length)
{ return null; }
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawdatas, 0, buffer, rawsize);
object retobj = Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
return retobj;
}
Here it is
|
|
|
|
|
Many thanks Master Cao! If I still can't get my WCF contract working I may just try serialize/de-serialize whole deal to byte[]
|
|
|
|
|
You welcome. Good luck with you project.
|
|
|
|
|
Oh bummer
<br />
{"Type 'XXXXX.MyAccount' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."}<br />
I suspect this is because MyAccount is actually a complex hierarchy containing a child collection...
<br />
class MyAccount<br />
{<br />
...<br />
public List<Invoicesgt; GroupList;<br />
}<br />
Eekkk... I was going to wire down an array of accounts (i.e. MyAccount[]) but now can't even wire down one single MyAccount... I desparation I tried this:
<br />
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())<br />
{<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
formatter.Serialize(stream, result);<br />
byte[] BinAcct = stream.ToArray());<br />
}<br />
But even then I ran into runtime exception, complaint was that class is not marked serializable (Although marked DataContract), looks like I got lucky with
<br />
DataContractSerializer dataContractSerializer = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
dataContractSerializer.WriteObject(memoryStream, Acct);<br />
btAccountSet = new byte[memoryStream.Length];<br />
Array.Copy(memoryStream.GetBuffer(), btAccountSet, btAccountSet.Length);<br />
}<br />
This finally get the job done (only serialization part, still stuck during deserialization).
<br />
1. Serialize side:<br />
DataContractSerializer serial = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
serial.WriteObject(memoryStream, oAcct);<br />
btPayload = new byte[memoryStream.Length];<br />
Array.Copy(memoryStream.GetBuffer(), btPayload, btPayload.Length);<br />
}<br />
<br />
2. Deserialize side: <br />
byte[] raw = (byte[]) GetPayload();<br />
serial = new DataContractSerializer(typeof(MyAccount));<br />
using (MemoryStream memoryStream = new MemoryStream(raw))<br />
{<br />
memoryStream.Seek(0, SeekOrigin.Begin);<br />
oAcct = (MyAccount) serial.ReadObject(memoryStream);<br />
}<br />
So, all good sending a single object, but still need to attempt sending/serializing a list of MyAccount (with subclasses)
Thanks
modified on Saturday, August 21, 2010 1:46 AM
|
|
|
|
|
Were you able to fix it??
With the sample code you've posted I was not able to find the problem.
|
|
|
|
|
hey yes, many thanks, working now and I just dodged a tight deadline! (Code I posted actually works, forgot to remove "Bummer" as initially when I posted the reply I was still having problem)
Thanks very much!
|
|
|
|
|
I have mp2 video file withount sound (mv2) and wav file.
I want to create new file containning them both.
i search over the web code for multiplexing mv2 and wav and i found nothing.
if anyone framiliar with an open source code or have General direction for doing that
it sure can help a lot
Thanks in advance
|
|
|
|
|
Why not simply drive FFMpeg[^]? It rocks, is stable, open-source and completely free.
/ravi
|
|
|
|
|
Hi guys,
I need help on how to obtain longitude and latitude location on my HTC advantage X7510. I have used the code sample provided by Microsoft and it did not work.Any one with an idea on how to make this work or on how I could build my own GPS apps from scratch?
Bravegee
|
|
|
|
|
Repost with Q & A - don't post the same in multiple places, it just duplicates work and annoys people.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Are you sure the example doesn't work? It may take some time for the GPS device to get a solid fixture etc. Do you receive an error? What's the reason why you think the code 'doesn't work'?
|
|
|
|
|
Thank you for responding.
The code does not give a GPS location however long I wait to get it.I used thesame codes on other device and it worked. I think the issue is with the device. Any clue why the code is not working on my HTC Advantage X7501 model?
Thanks a lot.
|
|
|
|
|
It would be so kind of you to provide an answer that could help me solve the problem with my application.
|
|
|
|
|
If I have an anonymous delegate can I do this:
foo bar = new foo();
bar.DoStuff += (s, e) =>
{
SomeStuff();
bar = null;
MoreStuff();
}
|
|
|
|
|
Even if you could (and I haven't tested it but I really hope you can't) from the point of the poor sod who would have to maintain that code, I would hunt you down and destroy you.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I know, it's horrible - I am just curious if it's permissable because it seems to work (although I know that's no guarantee it will always work) - as for maintenance it's perfectly maintainable.
|
|
|
|
|
RugbyLeague wrote: as for maintenance it's perfectly maintainable.
Deleting the object that raised the event during the event handler is maintainable?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
If it's permissable, valid code it is - if it isn't it is still maintainable but wrong.
|
|
|
|
|
Just because you can do something, doesn't mean you should...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|