|
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
|
|
|
|
|
i need that and also how to handle stored procedures also
Mohinder Singh
|
|
|
|
|
|
i want to declare a class in that i want to make a function i.e. conection and access it on the main form.and i want to use stored procedure.So how to do it with stored procedure can anuone give me the code...really urgent
Mohinder Singh
|
|
|
|
|
i'm not sure i usnderstand exactly what you mean - you need want to have a separate class that holds your data connection objects and reference that from a form?
|
|
|
|
|
Hi I am totally a new commer in VB or VB . Net i m trying to make a simple windows application. that has two textboxes in it. i want to make my own student class with two members Name and gpa. and two methods one to assign the values to the variables and the 2nd one to show them in the textboxes. and i want to access this class in another class by creating its object in it. i am having following problems.
i) textboxes r not accessible in my student class.
ii)when i added these variables and function in the Form1 class (for the textboxes to b accessible) and created the object of Form1 in my own class i was unable to access the variables and methods of Form1 class.
I am giving the code as well.
Public Class Form1
Inherits System.Windows.Forms.Form
Private name As String
Private gpa As Double
Public Function assignvalue()
name = InputBox("Enter the name of students")
gpa = InputBox("Enter the name of studentsFather")
End Function
Public Function showvalue()
textbox1.Text() = name
textbox2.Text() = gpa
End Function
Public Class MyClass
Dim s1 As New Form1
s1.assignvalue()
s1.showvalue()
End Class
End Class
now when i run this program it gives error on s1.assignvalue() and s1.showvalue()
D:\VB Projects\WindowsApplication1\Form1.vb(168): Declaration expected.
somebody plzz help me out
looking forward for help
Regards,
|
|
|
|
|
Well It would be good to get a better answer than this. Its a kind of scope problem and it seems naming a class myClass is not liked and similar conflict naming a variable name, they are keywords.
So I changed it a little bit
Public Class Form1
Inherits System.Windows.Forms.Form
Dim t1 As TextBox
Dim t2 As TextBox
Private name1 As String
Private gpa As Double
Public Function assignvalue()
name1 = InputBox("Enter the name of students")
gpa = InputBox("Enter the GPA")
showvalue()
End Function
Public Function showvalue()
TextBox1.Text() = name1
t1.Text() = gpa
End Function
Public Class displayme
Public Shared Function show()
Dim s1 As New Form1
s1.assignvalue()
s1.showvalue()
s1.Show()
Dim t1 = New TextBox
Dim t2 = New TextBox
s1.Controls.AddRange(New Control() {t1, t2})
t1.Location = New Point(20, 50)
t2.Location = New Point(20, 100)
End Function
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
displayme.show()
End Sub
End Class
|
|
|
|
|
Thxx Sir, but it isnt working eithr it is giving hell lot of errors
|
|
|
|
|
Sorry,
I think i made it worse. I will look at it, im just learning so it is interesting. Especially the scope part of it. Maybe try separating the classes a bit more, instead of having one inside another. But I am sure we will sort this out.
But it works if you keep your class outside the other class. I don't think nested classes are going to work!
Public Class Form1
Inherits System.Windows.Forms.Form
+windows Generated Code-----------
----------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New aClass
Label1.Text = f.myfunction
Label1.Text = f.showName
End Sub
End Class
Public Class aClass
Private strName As String
Private gpa As Double
Public Function myfunction()
strName = InputBox("Enter the name of students")
End Function
Public Function showName()
Return strName
End Function
End Class
|
|
|
|
|
Can someone give me the code for pins changed event of serialort in vb?
|
|
|
|