|
What does it do ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi everybody,
We have been having database replication problems the last few months so now I have to do my own database replication program.
We have a database saved state for all clients. We want to write a program which will look at both states, database and client, and just take the columns and values of the things that changed. so when I look at one table and compare it to the client I can see that on row x only the value of column y has changed. We want to put in a meschanism which works with bits, meaning when a column value changes it gets a bit of 1, if not it is equal 0.
My problem is I know I have 59 columns on 1 table, so for this table I need 59 bits which are 7 "Full" Bytes(pls correct me if I am wrong 1 Byte = 8 Bits) + 1 byte where only the first three bits are to be filled with and the rest null. How can I fill my Bytes with ones and zeros and how can I write them to the text file.
I have not had any experience working with bits and bytes till now and I really don't understand it....
Thank you in advance,
/Peace2u my friend
|
|
|
|
|
<code>
'To set bit number 3's value (0-based):
Dim bit3 as Boolean
Dim Value as ... 'This is the value to save columns data for each table
Value = iif ( bit3isTrue , 1, 0 ) And (2 ^ 3)'i.e. 0...0100
'Repeat it for each of 59 columns
'------------------
'To get bit number 3's value
bit3isTrue = Value And ( 2 ^ 3 )
'To Save data you only need to save Value
</code></
|
|
|
|
|
Have a look at the System.Collections.BitArray class.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I had a look at it, but didn't find a way to put the bitarray values into a byte.
Visual Studio said it can't convert a bitarray to a byte. Did I oversee something?
Do you have an example?
Thank you,
/Peace2u my friends
|
|
|
|
|
Example:
Bitarray a = new BitArray(59);
byte[] b = new byte[8];
a.CopyTo(b, 0);
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
Ok now I use
<br />
Dim MyBitArray As BitArray = New BitArray(MyBitLength)<br />
Dim MyBytes(BitsinByte) As Byte<br />
x = 0<br />
Do Until x = MyTable.Rows.Count - 1<br />
i = 0<br />
Line1a = ""<br />
Line1b = ""<br />
Do Until i = MyBitLength<br />
MyBitArray.Set(i, True)<br />
ColumnNames(i) = MyColumns.Rows(i).Item("name")<br />
i += 1<br />
Loop<br />
MyBitArray.CopyTo(MyBytes, 0)<br />
For j = 0 To MyBytes.Length - 1<br />
Line1a &= MyBytes(j)<br />
Next<br />
x += 1 <br />
Loop<br />
When I look at the values in MyByte it gives me 255, is that right?
Thank you in Advance,
/Peace2u my friends
|
|
|
|
|
Yes, a byte where all bits are set to one has the value of 255.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
Thank you. Do you know how I can write the byte value to a text file as byte or do I have to write it as text 255?
Thanks,
/Peace2u my friend
-- modified at 7:03 Friday 16th June, 2006
|
|
|
|
|
You can use the Convert.ToBase64String to encode the bytes into a reasonably compact format. Use Convert.FromBase64String to decode it.
Base 64 stores 6 bits in each character while still only using readable characters.
---
b { font-weight: normal; }
|
|
|
|
|
Hi. I use the Enum statement regularly, and I'm wondering if there's a similar statement where I can change the member's values? Because the Enum's members get declared as constants.. Please help me
----
Dim Sleepy as Boolean = True
If Me.Sleepy = True Then
Goto Sleep
End If
----
|
|
|
|
|
Nah - how about a Generics.Dictionary(Of String, Integer) ?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Or you could just make your own class with public variables and a public enum.
|
|
|
|
|
I want to learn crystal reports I mean how to show the table contents of database through crystal reports.Can u plz send me the steps to do that.
|
|
|
|
|
|
Hello,
Please help me to convert the belowing code to VB.NET.
Design event object
The event object will have a custom interface, since that is what WinFIOL uses to call the object.
class CWFEvent : public IWFEvent
{
int iCount;
IWFChannel * pIWFChannel;
DWORD dwThreadID;
void ReadPrintout(void);
public:
CWFEvent(IWFChannel *chnl);
virtual ~CWFEvent() { }
STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
STDMETHOD_(ULONG, AddRef)(void);
STDMETHOD_(ULONG, Release)(void);
STDMETHOD(Notify)(INT event, BSTR eventstr);
};
Implementation
Most of the code below is standard and can be found in many books about COM. The constructor takes a pointer to IWFChannel to be able to call methods in this interface.
CWFEvent::CWFEvent(IWFChannel *chnl)
{
iCount = 0;
pIWFChannel = chnl;
dwThreadID = GetCurrentThreadId();
}
STDMETHODIMP CWFEvent::QueryInterface(REFIID riid, void ** ppv)
{
if ( riid == IID_IUnknown )
*ppv = (IUnknown *) this;
else if ( riid == IID_IWFEvent )
*ppv = (IWFEvent *) this;
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
((IUnknown *) *ppv)->AddRef();
return S_OK;
}
STDMETHODIMP_(ULONG) CWFEvent::AddRef(void)
{
return ++iCount;
}
STDMETHODIMP_(ULONG) CWFEvent::Release(void)
{
if ( iCount == 1 )
{
// make sure message loop is terminated:
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
delete this;
return 0;
}
return --iCount;
}
STDMETHODIMP CWFEvent::Notify(INT event, BSTR eventstr)
{
if ( event == WFEVENT_PRINTOUT )
ReadPrintout();
return S_OK;
}
|
|
|
|
|
You can go to
http://www.developerfusion.com
................
|
|
|
|
|
I don't known C#,and there I got some error..
|
|
|
|
|
hi all,
i create an application to sending email's. this is the code i used.
Dim mailmsg As MailMessage
SmtpMail.SmtpServer = "127.0.0.1"
mailmsg = New MailMessage
mailmsg.To = txtFrom.Text
mailmsg.From = txtTo.Text
mailmsg.Subject = "demo"
mailmsg.Body = "Its a simple test"
mailmsg.BodyFormat = MailFormat.Text
SmtpMail.Send(mailmsg)
But i got an error 'Could not access CDO.Message object'
Please help me.
Thomas
|
|
|
|
|
Two possible reasons:
1. cdosys.dll is not installed on your machine. Usually it comes along with Outlook.
2. Your local SMTP server is not running.
_____________________________________________________________________________
I don't expect too much, all I want is your vote for Halbsichtigkeit.
|
|
|
|
|
I am using an application which is sending data to a web service (abt 256 KB) and after 1 min or so i am getting "Operation Time-out " exception error
Is there a limit to how much data we can send to web service?
I am not using any timer or any thing.
What can be the reason.
Need it urgently.
|
|
|
|
|
You should adjust the Timeout argument of the method/function you are using to send the data.
----
Dim Sleepy as Boolean = True
If Me.Sleepy = True Then
Goto Sleep
End If
----
|
|
|
|
|
Can anyone help me I want to make application that can convert from html to xml, or xml to html, asp to asp.net or asp.net to asp
using vb.net only.
Thanks
................
|
|
|
|
|
What specifically is it that you would need help with?
---
b { font-weight: normal; }
|
|
|
|
|
I want to convert a code from html to xml...
................
|
|
|
|