473,411 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

SQL update via vb .net

When I update an SQL record with the IP address received by my tcp listener
the SQL record has a sting of square symbols after the IP address. I
believe the squares represent the remaining blank bytes in the Buffer. How
can I trim these squares from my string? I have tried clientV = clientV.Trim
() and clientV = clientV.Trim(Nothing) to no avail.

I receive the IP address as such:
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)

SyncLock CurThread

clientV = (System.Text.Encoding.ASCII.GetString(Buffer))

I Then up date SQL:

Dim updateCMD As String = "UPDATE ManagedLists SET mlName = @clValue WHERE
mlID = 849;"

Dim sqlUpdate As SqlCommand = New SqlCommand(updateCMD, Me.SqlConnection1)

sqlUpdate.Parameters.Add(New SqlParameter("@clValue", SqlDbType.VarChar))

sqlUpdate.Parameters("@clValue").Value = clientV

Me.SqlConnection1.Open()

sqlUpdate.ExecuteNonQuery()

Me.SqlConnection1.Close()

Thanks for the Help!
Nov 21 '05 #1
2 4140
I am sending the IP address of the client as follows:

Dim Client As TcpClient
Dim Buffer() As Byte
Dim InBuff(100) As Byte
Dim heserver As IPHostEntry = Dns.Resolve(Temp)
Dim curAdd As IPAddress
For Each curAdd In heserver.AddressList
TempI = curAdd.ToString()
Next
'1. Send IP address to server.
Buffer = System.Text.Encoding.ASCII.GetBytes(TempI.ToString )
Client.GetStream().Write(Buffer, 0, Buffer.Length)
Server Side code:

Dim CurSocket As Socket
Dim Buffer(100) As Byte
Dim Bytes As Integer
While Not StopListener
If CurSocket.Available > 0 Then
' 1. Receive IP Address from client:
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)
SyncLock CurThread
clientV2 = (System.Text.Encoding.ASCII.GetString(Buffer))
End SyncLock
Exit While
End If

I then take take clientV2 and update a SQL record and that is when the
square symbols show up.
NOTE: If I write clientV2's value to the config.xml file I find "�"
repeated over and over - the number of bytes in the IP address. I found that
"�" is apparently an illegal NULL XML value.
Thanks for all the help!

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:xF****************@TK2MSFTNGXA01.phx.gbl...
Hi

1. What did you get in the code line below.
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)

2.Normally, if we send 5(e.g.) bytes in sender, the receiver will get 5
bytes too. So if the squares is not what you had send, it should be
something wrong with the TCP/IP app.
Another way is that, if the Buffer is not empty, and the Bytes did not
equal to the Buffer.Length, then in this case, we can just stripe the
Bytes
count bytes from the Buffer and do ascii decoding.

3. Please make sure you are doing ascii encoding in the sender

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #2
Hi Kenneth,

From your code snippet it seems that the code is OK.
Based on my understanding, the problem should be of no business with the
SQL, because the strange data is gotten before you call the SQL statement.
The problem is that you send A but you get AXXXXXX.
If I misunderstand, please let me know.

So far please check the suggestion I posted in my last post.
1. Debug.WriteLine(TempI.ToString) before sending,
Buffer = System.Text.Encoding.ASCII.GetBytes(TempI.ToString )
Client.GetStream().Write(Buffer, 0, Buffer.Length)
2. Note the Buffer.Length, Buffer
3. In the receive side,
Confirm the Buffer is emtpy,
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)
4. note the Bytes, Buffer.Length, and compared it with the data NOTED in 2.
5. compared Buffer with the Buffer in 2.

If you still have any concern, please send me a simple reproduce sample
together with the reproduce steps and the test data you are using.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
27
by: VK | last post by:
<http://www.jibbering.com/faq/#FAQ3_2> The parts where update, replacement or add-on is needed are in <update> tag. 3.2 What online resources are available? Javascript FAQ sites, please...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.