|
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?
|
|
|
|
|
How do you go about making your class accessible to other projects ?
Like say you have a custom messagebox ?
-- modified at 21:30 Friday 7th July, 2006
|
|
|
|
|
Put it in a DLL.
Best,
Jun
|
|
|
|
|
Sorry about this question but how do you make the dll ?
|
|
|
|
|
had inserted datetime values in databse field like '" + DateTime.now + "'
now i want to comapre valus using betwwen operator of SQL
i.e where dbtime between '" + dtp1.value + "' AND '" + dtp2.value + "' but it does not show any record i think critera of where class did not match.
how to compare them so that it show correct result
Tasleem Arif
|
|
|
|
|
Can you paste your code here? might be easy to help you that way.
Difficult - > Challenging, this simple replacement made me take my life little easy;)
|
|
|
|
|
str="INSERT INTO tblHistoryLog(UserId,UserAction,TableName,ActionDate,TrDoneOn) VALUES('" + CheckValues.strUserId + "','NEW RECORD','USER TABLE','" + DateTime.Now + "','" + cmbTAUserId.Text + "')";
where ActionDate datatype if datetime.
i had inserted record in the table and inserted properly.
the query that uses the comparison
"SELECT * FROM tblHistoryLog WHERE (ActionDate BETWEEN #"+ dtpTo.Value +"# AND #"+ dtpFrom.Value +"#)"
but it gives the no result
i had tried to use this but it does not compile so i had to use above
"+ #dtpTo.Value# +" AND "+ #dtpFrom.Value# +"
Tasleem Arif
|
|
|
|
|
What database are you using?
What is the data type of the field in the database?
---
b { font-weight: normal; }
-- modified at 8:07 Saturday 8th July, 2006
|
|
|
|
|
datatype is datetime and i m using sql server2000
Tasleem Arif
|
|
|
|
|
Then you shouldn't use # arounds the date values. That is use with MS Access.
---
b { font-weight: normal; }
|
|
|
|
|
I assume that you are using either ASP.NET or windows forms as client. Try following:
"ActionDate BETWEEN" & " '" & Convert.ToDateTime(dtpFrom.Value).ToLongDateString & "' AND " & " '" & Convert.ToDateTime(dtpTo.Text).ToLongDateString & "'"
I also notice in your code, you are going from To...From! usually it is From...To right?
Hope this helps.
Difficult - > Challenging, this simple replacement made me take my life little easy;)
|
|
|
|