|
Hello,
I have a TCP connection in which the following is sent to me:
typedef struct<br />
{<br />
int msgLength;<br />
int msgType;<br />
int seqNumber;<br />
int version;<br />
char data[1024];<br />
} XXXXXXXXXXXXXX;
The msg length: the toal msg length, i.e, sizeof (msgLength)+ sizeof(msgType)+sizeof(seqNumber)+sizeof(version)+realDataLength(276).
msgType: 1
seqNumber: squentially increased from 1.
version: 0
data: store the real content.
All the above variables except data[1024] are Big Endian. My problem is that I need to convert the big endian vars to little endian so that the windows service I have (written in VB.NET) can use them.
Here is a sample of what I thought would work:
.....
i = stream.Read(bytes, 0, bytes.Length)
Try
data = System.Text.Encoding.BigEndianUnicode.GetString(bytes, 0, 15)
........
I thought this would convert the first 16 bytes (the four integer vars from the C structure) to little endian..but nope. Then I tried the first four bytes, etc. No luck. Does anyone know how this can be accomplished in VB.NET?
Thanks.
"Half this game is ninety percent mental."
- Yogi Berra
If you can read thank a teacher, if you can read in English, thank a Marine.
|
|
|
|
|
Use the IPAddress.NetworkToHostOrder method. Not the best place for it to live, IMO, it would have been better as a member of the Convert class.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
|
how can i let my program know that the PC is currently not in use by the user?
for Xample "like how Screen saver works"....
Militiaware
Faris Madi
|
|
|
|
|
A screensaver would be triggered via a timer attached to a systemwide hook on the mouse and keyboard.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, i made a custom control for data access, someone else is gonna use it, but i dont want them to see the code nor how its implemented, i created a new project and added a reference to that control, when i was running the program, i put a breakpoint in a call to a method of my control and it loaded the source code of the control and by pressing F8 i could see how it is implemented, i could even modify it directly from this other project.
Whats the right way to release a custom control and not letting anyone who uses see the code??
I want my control to be used just the way we use the combobox that comes with .NET
Thank you
|
|
|
|
|
there's some steps you should follow to protect your control..
like Using strong name and signing assembly because a strong name prevent of name spoofing - if you have developed your own Windows control, it is easy for as outsider to create a version of your control in order to fool people into believing it was yours. in order to prevent name spoofing, the assembly must be aware of the publisher.
Militiaware
Faris Madi
|
|
|
|
|
On someone elses machine, the source code will NOT be available in the debugger. They won't see your source or your implementation or anything else.
Though, you can still open up the assembly and view the code using .NET Reflector.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need some help pulling XML data into data grid. I have been working with vb.net for awhile but do not have any experance with XML. Please assist. I am using VS 2005 express for VB, so the ADO is verry limited.
Thanks
George
|
|
|
|
|
I'm using the following code to add a record to a SQL database.
When the record is inserted how can I get the primary key value the database assigns to a field in that record when it is inserted.
Thanks
Dim DBCommand1 As SqlCommand
NonQueryText = "insert into mytable(field1)values(@field1)
DBCommand1 = New SqlCommand(NonQueryText, Connection1)
DBCommand1.Parameters.Add("@field1", SqlDbType.Char,10, "field1").Value = "abc"
Connection1.Open()
DBCommand1.ExecuteNonQuery()
|
|
|
|
|
Use the query "select @@identity" to get it.
@@identity contains the last identity created with the same connection.
---
b { font-weight: normal; }
|
|
|
|
|
I believe @@IDENTITY is for Access DB, if you are using SQL 2000 use SCOPE_IDENTITY()
|
|
|
|
|
The @@identity property works in Access also.
You can use scope_identity() or @@identity in SQL Server. They work very similar, the only time there is any difference between them is if you are using triggers that also insert records.
---
b { font-weight: normal; }
|
|
|
|
|
Using the following sql throws an error
"select @@contactdataid from contactdata"
What else must I do? Thanks.
|
|
|
|
|
Just use the query "select @@identity", as I said.
---
b { font-weight: normal; }
|
|
|
|
|
Sorry to ask elementary questions here but @@identity does not have any value. After I execute the query "select @@identity" how can I get this value into a varable? How does it know which field in the table to use?
|
|
|
|
|
The query only returns one field in one record. Use ExecuteScalar to run the query and get the single value.
---
b { font-weight: normal; }
|
|
|
|
|
I am doing a project that requires me to send the users and alert message to their cellphone as soon as any new changes made to the service.. I am presently using vb.net to develop this online application.. how do i go about sending alert message to the person's cell phone. if anyone have the coding for it.. please help..
Nab
|
|
|
|
|
Not sure if cellphones have this, but when we wanted to send system outage messages to our pagers we would send an email to the email gateway provided by the pager company with an address of the beeper number.
EX. 805551212@cellphone.com, you need to check with the cellp[hone provider to see if they support this.
Matthew Hazlett
|
|
|
|
|
now days every E-commerce project required alert message to cell phone
this is very useful, if any body have code or guidance please post.
|
|
|
|
|
Hi all,
In Visual Basic 6 I'm trying to insert data into a db that is retrieved from a file. When I execute the insert statement ("Connection.Execute") I receive some errors because there are records that have apostrophes. How can I escape this character?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Let me gues, you''re concatenting SQL statements together like this:
Dim sql As String
sql = "INSERT INTO table field1, field2, field3 VALUES ('" & textbox.text & "', '" & textbox2.text & "' " & textbox3.text & "')"
This is completely the wrong way to do it and you'll run into escaping problems, like you've discovered, and you also open yourself up to SQL Injection attacks.
Use parameterized queries and you won't have this problem at all.
See this[^] article by Collin Angus Mackay for more information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave, now after reading the article I'm more concerned about the escaping the apostrophes and I've parameterised the query.
Thanks,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Yeah, the Parameter class takes care of escaping any characters that need it itself, as well as checking for certain types of injection attacks.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You escape apostrophes with apostrophes.
For example, this string...
"Bob's Data"
...becomes this...
"Bob''s Data"
|
|
|
|