|
Lisana wrote:
thanks Michael
Who? Oh, that last part there is a sig. I was quoting Michael, but I'm not Michael.
Well, my suggestion is to try and understand it, and then modify the code. The code snippet there is usually well commented, and you could always google for parts you don't understand. Copy and paste usually doesn't work as intended
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I'm sorry to get your name wrong..
Thanks Nick!
Lisa
|
|
|
|
|
Hi,
i'm trying to write a little telnet client in vb.net and I'm going crasy with it.
here is the main code :
Private Function sendReceiveTCP(ByVal message As String) As String<br />
Try<br />
' Translate the passed message into ASCII and store it as a Byte array.<br />
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)<br />
<br />
' Get a client stream for reading and writing.<br />
' Stream stream = client.GetStream();<br />
Dim stream As System.net.Sockets.NetworkStream = msocket.GetStream()<br />
<br />
' Send the message to the connected TcpServer. <br />
stream.Write(data, 0, data.Length)<br />
<br />
Console.WriteLine("Sent: {0}", message)<br />
<br />
' Receive the TcpServer.response.<br />
' Buffer to store the response bytes.<br />
data = New [Byte](100000) {}<br />
<br />
' String to store the response ASCII representation.<br />
Dim responseData As [String] = [String].Empty<br />
<br />
' Read the first batch of the TcpServer response bytes.<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)<br />
Console.WriteLine("Received: {0}", responseData)<br />
<br />
Return responseData<br />
Catch ex As ArgumentNullException<br />
Console.WriteLine("ArgumentNullException: {0}", ex)<br />
Catch ex As System.Net.Sockets.SocketException<br />
Console.WriteLine("SocketException: {0}", ex)<br />
End Try<br />
End Function<br />
Juste before call this method, I open the socket like this
msocket = New System.Net.Sockets.TcpClient(servername, port)
Then I send some data to it like this
Me.sendReceiveTCP("login myuser")
And the problem come now when I try to send the second data with the following code :
Me.sendReceiveTCP("pass *******")
When debugging step by step, I can notice that the problem occurs on
<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
The program hang and the only thing to do is to stop it.
Any1 know where I'm wrong ?
thx
Sybux
|
|
|
|
|
Your Read code is is blocking call. If there is no data to read, the .Read method will block further execution until data is available. You should check to see if there is data to read by checking the streams DataAvailable property. The following example should give you an idea: (Also, the .Read method will return an Integer, not an Int64...)
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As String = ""
Dim numberOfBytesRead As Integer = 0
' You could add code to this loop to wait a certain number of seconds before timing out.
Do While Not myNetworkStream.DataAvailable
Application.DoEvents()
Loop
' Incoming message may be larger than the buffer size.
Do
numberOfBytesRead = myNetworkStream.Read(myReadBuffer, 0, myReadBuffer.Length)
myCompleteMessage = [String].Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead))
Loop While myNetworkStream.DataAvailable
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've corrected my code with yours and I still got problem.
The change your code made is that now the program dosen't hang. When I send my second sendReceiveTCP, the code loop on the
<br />
Do While Not myNetworkStream.DataAvailable<br />
Application.DoEvents()<br />
Loop<br />
and suddenly it goes out of the sub, even the calling sub so that I never receive answer from my TCP Server.
|
|
|
|
|
I am trying to only submit the certain rows from the dataTable that have been modifed with 2 ways to which both of them result in all the rows being submitted.
The first way is using the GetChanged method of the dataTable, and it returns all the rows. The second way is using the if myRow.RowState = DataRowState.Modified, and it says they were all modified.
I tried to insert this before the fill operation:
.AcceptChangesDuringFill = True
after having problems, assuming that it was during the fill that the rowState was set to modifed, but no luck.
I have also tried after inserting the data into the table:
myTable.AcceptChanges.
I am pretty sure that nothing else touches the rows after that so they should not get there rowStatus changed.
If anyone can see what I am doing wrong, or leaving out I would appreciate the help.
Thanks
|
|
|
|
|
It seems that you are doing something wrong in your code. I have just tried that on my computer and GetChanges() is working just fine.
I tried something like this
Me.DataGrid1.DataSource = Me.Dataset11.authors.GetChanges(DataRowState.Modified)
and the GetChanges() returned only the rows that I modified
Give me some more of your code if you like and I might find the solution.
Better luck next time
sony speed
|
|
|
|
|
thanks for the help.
What seemed to be the problem was that initially I didn't have the acceptChanges() in there and after I inserted it I forgot that I had another method that was stipping out all the null values and that was making chnages once again. All is gooood now.
|
|
|
|
|
I am having a hard time getting the getChanges to retrieve the changes that were performed on the last row of the data. Since the user is not able to create rows, nothing really happens when the hit the enter key on the last line. I suppose I could always have an extra blank row at the bottom of the grid, but is there a better way to deal with this?
|
|
|
|
|
Hi,
I have created a form to be used by a user. On the form, the user may add one or more controls (textboxes). I would like the user to be able to resize these textboxes using the MOUSE.
I was wondering if anyone has an idea on how to do that or if it is possible?
The idea is similar to the way we are able to resize the control during our design time, which is vb.net's runtime.
Thanks!!
Any suggestions at all will be greatly appreciated...!!
RedDragon
|
|
|
|
|
I am a little confused on this subject. If a person has a a few tables that they have to join, and they do this through a dataAdaptor, are the update, insert, etc statements that are generated good for all the tables?
Only one table out of the tables that are joined needs to be updated, so if it is included in the dataAdaptor, will it be properly updated. The reason that I am confused is that I am reading Francesco Balena's book (very good book) and there is discussion of either using seperate queries for the tables then performing the join on the client side, or making a single query then manually extacting some of the queried data into the seperate tables on the client side. So I am a little confused with what dataAdaptors can and can't do.
Thanks for the help.
|
|
|
|
|
ok I see that after you make the join that the other queries are not created for you, so I guess you can't do it that way.
|
|
|
|
|
seeing as there is only one table that is being updated maybe I just assign the update string...sometimes I am a little slo
|
|
|
|
|
Hi everyone -
I'm really near to getting insane. I have a .Net Remote Application. My ServerObject listen at a special Port.
Each Client can call a function "login" to register itself at the server.
Servercode:
Public Sub _login(ByRef client As IClient) Implements IServer._login
If (Me._clients.ContainsKey(client._guid)) Then
Me._logout(client)
End If
Me._clients.Add(client._guid, client)
End Sub
_clients is a Hashtable !!!
Clientcode:
Public Function _connect(ByVal ipAddress As String, ByVal port As String) As Boolean Implements IClient._connect
Dim result As Boolean
Dim myThread As Thread
myChannel = New TcpChannel(0)
ChannelServices.RegisterChannel(myChannel)
remServer = CType(Activator.GetObject(GetType(IServer), "tcp://" + ipAddress.Trim() + ":" + port.Trim() + "/control.rem"), IServer)
Do While Not result
Try
remServer._login(Me)
result = True
Catch e As Exception
result = False
myThread = Thread.CurrentThread
myThread.Sleep(1000)
End Try
Loop
Return result
End Function
Actually, everything works fine. But after a time, when i do nothing at all, the hashtable is just empty, although the client is still up.
I also tried to set the lifetime of the server-object to infinite, but somehow it did not worked.
can someone please help me out of my mess?
if you need more code, just let me know.
thanks to all!
tom
|
|
|
|
|
You probably created a new server object each time and the hashtable _clients is not a shared variable. Each time you call remServer._login, you are using a new server object (and hence a new hashtable).
First, you need to make the _clients a shared (static) variable.
Then, modify your _login code as follows to provide thread safety:
Public Sub _login(ByRef client As IClient) Implements IServer._login
SyncLock Me._clients
If (Me._clients.ContainsKey(client._guid)) Then
Me._logout(client)
Else
Me._clients.Add(client._guid, client)
End If
End SyncLock
End Sub
Good luck.
My articles and software tools
|
|
|
|
|
i tried this out but it didn't work.
i found out, that, if i run a thread, that always calls a function on my remote objects every 1 second, everything works fine.
so my guess is, that the remote objects are destroyed after a time, when they are not used.
i also tried to change the lease-time of my objects, but i don't know how to set the lifetime of an MarshalByRef Object to infinite ... any idea?
|
|
|
|
|
Is it possible to run an application from within another application?
My current application:
The user selects an image from a thumbnail list that is displayed in a ListView. The full image is then displayed in a PictureBox.
What I would like to do:
When the user selects a thumbnail image I would like the larger image to open in an image viewer such as VuePrint Pro.
The tricky part is that I want VuePrint Pro to open within my application and in the same “foot print” as the PictureBox so that I can still have control of it from within my application.
Thanks
Brad
|
|
|
|
|
Brad Fackrell wrote:
The tricky part is that I want VuePrint Pro to open within my application and in the same “foot print” as the PictureBox so that I can still have control of it from within my application.
You can launch the external application, but you can't tell it where to render itself. Your application cal only have control like that if your external application comes with a COM library, like Word or Excel does, that exposes the functionality of the app through a control, like an ActiveX control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
you can't tell it where to render itself
...that is what I was afraid of.
I did a little digging and found the Kodak Image controls in the COM library. Have you had any experience with that?...good or bad??
Thanks
Brad
|
|
|
|
|
I haven't used them myself, but I've seen mixed reviews running around on the VB sites. Some people have success with them, some don't. But, in the cases where there wasn't any success, I have to question the abilities of the programmer, their image manipulation goals, and what they expect of out the Kodak components.
I haven't come acrossed any documentation for them either, but, then again, I wasn't looking for it...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks.
I'm searching for more info about them right now.
Brad
|
|
|
|
|
what if you want different table styles pointing to the same table. The app that I am working on is one that is used to correct tests. There is more than one type of error. Right now I have all the data being retrieved and thrown into the same table. I may have to change this is base the query on the correction mode and insert the data into different datatables, I really should do this, but I am still curious of the present problem.
I would like to create tablestyles, which I though that I did, so that in the different correction modes different columns are displayed, but I get an error when I try to do this:
<br />
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll<br />
<br />
Additional information: The data grid table styles collection already contains a table style with the same mapping name.<br />
Now they are the same mapping name, because the mapping name is the name of the table right?
Thanks for the help
|
|
|
|
|
hey kowplunk, sorry about the delay in my response, i was out of town for a few days.
anyways, the cleaner way to handle it would be to have the different data loaded into different tables and have the appropriate tablestyle handle the appropriate table. however, i can't say for sure that this is the case as i have no idea what the table structure looks like, what the resulting data looks like etc.
i guess if you have the same data but you want to display it in different ways you could just load everything into the same table, then when you need to change the way the data is displayed, release the mapping name of the current tablestyle (via code) and then set the mapping name of the secondary one. as you found out you can't have two tablestyles pointing to the same table at the same time.
however, if you're intention is to show different columns etc. at different points, i think you might be better off with the multiple table solution.
-jim
|
|
|
|
|
Thanks for the help. Actually the error message was pretty descriptive. In the different styles that I had there was column mapping names that were the same and it doesn't like that, but it is easy to change. Everything is working awesome now. Thanks again.
|
|
|
|
|
I have to read a .xsd schema file by using visual basic code.Vb.net is not necessary.The code mst be in Visual basic.Give me idea.
|
|
|
|
|