|
There are LOTS of problem with this code. The most obvious is that your compairing a byte read from the file to the length of the file! Why? By doing this, you're more than likely truncating your reading of the file, so that's a source of corruption.
Do While fs.ReadByte <= fs.Length
Now, you've read a byte from the file and didn't do anything with it, then you read more bytes into the buffer, ignoring the byte you already read and dropped(!). There's another source of corruption.
numBytesRead = fs.Read(bytesToSend, i, bytesToSend.Length)
Now, in your server code, you're indidscriminately writing blocks of 1024 bytes to your image file, completely ignoring who many bytes were actually read from the stream! You have to determine how many bytes were read from the stream so you can only write than many bytes to the file! Without that, especially at the end of the file, you'll be writing more than was actually sent to you. Another source of corruption...
Do Until (NWStream.DataAvailable = False)
' How many bytes were read here??
NWStream.Read(buffer, 0, buffer.Length)
' How many are you writing here??
fs.Write(buffer, 0, buffer.Length)
Loop
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How i can devide two number in the same text field and return the result
the operation is 30/20 this is in the textbox1 then i need the result 1.5
Amarni
|
|
|
|
|
you'll have to split the string first using some form of delimiter (an operator perhaps), parse them, perform the calculation and then return the result.
|
|
|
|
|
i know that.. but how could i use this way ??????
and id the user make an error like this 30//10 or 30/10/
so what is the solution for this problem
Amarni
|
|
|
|
|
Try to split the text then call divide function.
Dim num() As String = txtInput.Text.Split(CChar(vbTab))<br />
'//Throw number to function<br />
Divide(num(0), num(1))
Hope this help.
|
|
|
|
|
hello can anyone helop me by telling how to make a connection class and how to work with stored procedures in vb.net.
Mohinder Singh
|
|
|
|
|
How about following up on the replies in the previous thread[^] instead of asking the same question again?
---
b { font-weight: normal; }
|
|
|
|
|
can u please tell me how to that thing
Mohinder Singh
|
|
|
|
|
Go to your profile and click on "Messages Posted". There you will find the messages you wrote, and you can view the previous thread.
---
b { font-weight: normal; }
|
|
|
|
|
I am trying to connect to a remote server using a tcpclient and then check if the connection was successful before continuing on with the rest of the program.
i am unsure of how to check if the connection was successful.
|
|
|
|
|
You can do two things:
1) Try to catch exceptions. TcpClient.Connect throws a number of exceptions, among which are SocketException and ObjectDisposedException.
2) Get last error.
Best,
Jun
|
|
|
|
|
i was able to connect to an Excel file using oledb in vb6.0 but there are some unresolved issues
1. rs.Recordcount to retrieve the no of rows in the excel worksheet(i.e 8rows) returns more(6636rows) than the data i have in the excel worksheet.
2. I want to read the header i used so that i can use them as fields in my access db table. but ado start reading the real data instead of starting from the header row.
i am using office-xp. With office xp, reference to Microsoft Office Object library does not allow me to use excel application object in my vb. I want to use this object to open the workbook, get the Worksheet name and read from the worksheet.
any help as regards will be appreciated.
thanks
t.aransiola
|
|
|
|
|
hi everyone, plz plz plz i need help on my pb, i have a project to present on 12 of july & i still can find the solution to my pb
i am using a visual basic 6 platform & i am using a flexgrid control ,i want to select each row appart & i want to wait 0.5 sec then select the next row. the pb is that the row keep on selected but i can't see the selected rows after the 10th row unless i click on the msflexgrid scrollbar.
is there is any way to make it move without pressing.
this is my code:
Dim i As Long
For i = 0 To 33
Me.MSFlexGrid1.Row = i
Me.MSFlexGrid1.Col = 0
Me.MSFlexGrid1.SetFocus
Me.MSFlexGrid1.ColSel = Me.MSFlexGrid1.Cols - 1
Call wait(0.5) ' function to wait
Next
End Sub
so the pb is that i can see the 1st 10 rows but the other rows i can't
plz plz i need help on it
waelhawari
|
|
|
|
|
II WORK IN CRYSTAL REPORT AND I TRY TO VIEW MANY COLUMNS IN MY REPORS AND THE NO OF COLUMNS CANN'T BE PUT IN ONE PAGE BECAUSE I DIR TOO MANY COLUMNS HOW I DIVIDE MY COLUMNS INTO 2 OR 3 PAGES
MA_REFAY
|
|
|
|
|
|
Hi
I wonder if I can make a table to an existing database without using the
statement "Create Table".
I want to use the Datatable with DataColumns and DataRows I have made. Is
there a way I can connect to the database in code and add this DataTable? If so,
please tell me
Fia
|
|
|
|
|
I don't believe you can do that. I think you have to create the table with SQL code first.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
As far as I know you can't do it that way. You have to create tables using the proper SQL syntax.
From what I remember when talking to a SQL engineer @ MS even the SQL Enterprise manager just talks SQL to the DB engine when creating and deleting tables.
My Blog[^] FFRF[^]
|
|
|
|
|
That's part of the SQL specification. The engine and system databases are managed by the same language used to manipulate user databases.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
you can add reference to "Microsoft.SqlServer.Smo" and use it's classes to manage (create, alter, drop) any SQLServer objects - tables, procedures, constraints, indexes, foreign keys etc.
Very useful.
|
|
|
|
|
That works if your using SQL Server 2005. Other versions, I recommend using the SQL method.
In either case, he wanted to do it just by adding a new DataTabel object to his DataSet, which won.t work at all.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Everybody,
I am trying to upload a new file to a Web Server over a VB.NET App. I am using httpWebResponse and httpWebRequest to do so with a a PUT method. The server returns always a 501 Not Implemented Error. The code works fine on all XP Maschines but not on our Windows 2000 Server. I did have URL Scan installed on the server but killed it because I thought that was the cause of my problems but with no success.
Here is the code:
Dim Response As String = Nothing, FileSize As Double = 0
Try
UploadFile = False
If SourceLocation.ToString.Trim <> "" And DestinationLocation.ToString.Trim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create(New Uri(DestinationLocation.ToString.Trim)), System.Net.HttpWebRequest)
UploadRequest.Credentials = Credential
UploadRequest.Timeout = 60000000
UploadRequest.Method = "PUT"
UploadRequest.ServicePoint.Expect100Continue = False
UploadRequest.ContentLength = New System.IO.FileInfo(SourceLocation.ToString.Trim).Length
FileSize = UploadRequest.ContentLength.ToString.Trim
'To set Upload Stream settings
Dim SourceStream As New System.IO.FileStream(SourceLocation.ToString.Trim, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream = UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0, CurLocation As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
While Position <> 0
RequestStream.Write(Buffer, 0, Position)
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
CurLocation += Position
End While
'To upload Stream on Remote system
Dim WebResponse As System.Net.HttpWebResponse = CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New System.IO.StreamReader(WebResponse.GetResponseStream())
Response = ResponseReader.ReadToEnd()
UploadFile = True
RequestStream.Close()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation.ToString.Trim = "" Then
Call MsgBox("Source Location is missing")
ElseIf DestinationLocation.ToString.Trim = "" Then
Call MsgBox("Destination Location is missing")
End If
Catch ex As Exception
Call MsgBox(ex.ToString)
End Try
Thank you in advance,
/Peace2u my friends
|
|
|
|
|
Basically, 501 means that the server doesn't support the PUT configuration you gave it. You might want to try reducing that 60000000 millisecond timeout to something like 30000. You might also want to try sending a smaller file, to see where that limit is. Some of these things you can change on the server to support higher limits, but I have no idea where. You might want to ask in the ASP.NET forum for that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, i'm new here. I'm trying to create a Desktop in VB2005 but all i have found is how to do so in VB6. Please can you help me.
|
|
|
|
|
So what's wrong with translating the VB6 code? It's not going to be that different...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|