Click here to Skip to main content
15,888,454 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Textbox Multiple line Problem Pin
Nilesh Hapse12-Mar-08 1:12
Nilesh Hapse12-Mar-08 1:12 
GeneralRe: Textbox Multiple line Problem Pin
Vimalsoft(Pty) Ltd12-Mar-08 1:29
professionalVimalsoft(Pty) Ltd12-Mar-08 1:29 
GeneralRe: Textbox Multiple line Problem Pin
Vimalsoft(Pty) Ltd12-Mar-08 1:39
professionalVimalsoft(Pty) Ltd12-Mar-08 1:39 
GeneralRe: Textbox Multiple line Problem Pin
Nilesh Hapse12-Mar-08 1:52
Nilesh Hapse12-Mar-08 1:52 
GeneralRe: Textbox Multiple line Problem Pin
Adam Loudermilk12-Mar-08 13:19
Adam Loudermilk12-Mar-08 13:19 
AnswerRe: Textbox Multiple line Problem Pin
Vimalsoft(Pty) Ltd12-Mar-08 20:03
professionalVimalsoft(Pty) Ltd12-Mar-08 20:03 
GeneralUSB programming Pin
duo!@#12-Mar-08 0:05
duo!@#12-Mar-08 0:05 
GeneralError reading large file from the webserver using HttpWebRequest Pin
Webber7711-Mar-08 22:04
Webber7711-Mar-08 22:04 
Hi all,

Could anyone help me?
I'm trying to get file from the web (initialy local webserver) and save it to the database after reading. If the files are small sized (up to 2Mb) - everything works fine - files can be uploaded and then opened from a database (I use another class to display the content of MSSQL image field and it's not a matter of this thread). BUT if the filesize is greater - documents can not be opened, though if I save them the size is equal to the original.

Here is the code I'm using for downloading file from the webserver and post it to the database:

Private SqlConnection1 As New System.Data.SqlClient.SqlConnection
Private addfile As New System.Data.SqlClient.SqlCommand
Private strURL As String = "http://datcserver:1234/K2Workflows2/file5M.doc"


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sServer As String
sServer = "MYSERVER"

Dim sUID As String
sUID = "myuser"

Dim sPWD As String
sPWD = ""
Dim sConStr As String
sConStr = "Server=" & sServer + ";"
sConStr &= "UID=" & sUID + ";"
sConStr &= "PWD=" & sPWD + ";"
sConStr &= "DataBase=DBNAME;"

Try
SqlConnection1.ConnectionString = sConStr
addfile.Connection = SqlConnection1
addfile.CommandType = System.Data.CommandType.Text
addfile.CommandText = "Insert into FILES (proc_id,file_body,title,description,type,version,createdby,modifiedby,createddate,modifieddate) Values (@procid,@filebody,@title,@description,@type,@version,@createdby,@modifiedby,@createddate,@modifieddate)"

Dim DocName As String
DocName = strURL.Substring(strURL.LastIndexOf("/") + 1, strURL.Length - strURL.LastIndexOf("/") - 1)

Dim oRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
oRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
oRequest.AllowWriteStreamBuffering = False
Dim oResponse As System.Net.HttpWebResponse = CType(oRequest.GetResponse, System.Net.HttpWebResponse)
Dim br As System.IO.BinaryReader = New System.IO.BinaryReader(oResponse.GetResponseStream)
Dim FileLen As Integer = oResponse.ContentLength

Dim Input(FileLen) As Byte
br.Read(Input, 0, FileLen)


addfile.Parameters.Add("@filebody", System.Data.SqlDbType.Image).Value = Input

addfile.Parameters.Add("@procid", System.Data.SqlDbType.Int).Value = 777
addfile.Parameters.Add("@title", System.Data.SqlDbType.NVarChar, 255).Value = DocName
addfile.Parameters.Add("@description", System.Data.SqlDbType.NVarChar, 255).Value = "Master version of original document - created automatically when the workflow started."
addfile.Parameters.Add("@type", System.Data.SqlDbType.NVarChar, 1).Value = "M"
addfile.Parameters.Add("@version", System.Data.SqlDbType.Int).Value = 1
addfile.Parameters.Add("@createdby", System.Data.SqlDbType.NVarChar, 255).Value = "Me"
addfile.Parameters.Add("@modifiedby", System.Data.SqlDbType.NVarChar, 255).Value = "Me"
addfile.Parameters.Add("@createddate", System.Data.SqlDbType.DateTime, 8).Value = DateTime.Now
addfile.Parameters.Add("@modifieddate", System.Data.SqlDbType.DateTime, 8).Value = DateTime.Now

SqlConnection1.Open()
addfile.ExecuteNonQuery()
br.Close()
oResponse.Close()

Catch ex As System.Exception
Throw New System.Exception(ex.Message)
End Try

SqlConnection1.Close()
End Sub



What is wrong here?
Thanks for any assistance!
Generaltext box validations Pin
MS Lee11-Mar-08 21:32
MS Lee11-Mar-08 21:32 
AnswerRe: text box validations Pin
AndrewVos12-Mar-08 3:08
AndrewVos12-Mar-08 3:08 
GeneralPassword Expiry Pin
manowj11-Mar-08 20:19
manowj11-Mar-08 20:19 
GeneralRe: Password Expiry Pin
Steven J Jowett12-Mar-08 2:17
Steven J Jowett12-Mar-08 2:17 
GeneralRe: Password Expiry Pin
manowj12-Mar-08 2:23
manowj12-Mar-08 2:23 
Questioncombo box coding Pin
deyrla11-Mar-08 17:24
deyrla11-Mar-08 17:24 
GeneralRe: combo box coding Pin
Ravenet11-Mar-08 17:34
Ravenet11-Mar-08 17:34 
GeneralRe: combo box coding Pin
MS Lee11-Mar-08 23:49
MS Lee11-Mar-08 23:49 
Generalto ecrypt userid and password Pin
phoopwint11-Mar-08 17:14
phoopwint11-Mar-08 17:14 
GeneralRe: to ecrypt userid and password Pin
Justin Perez12-Mar-08 3:18
Justin Perez12-Mar-08 3:18 
GeneralExport to Excel directly Pin
herag11-Mar-08 16:45
herag11-Mar-08 16:45 
GeneralRe: Export to Excel directly Pin
Ravenet11-Mar-08 17:37
Ravenet11-Mar-08 17:37 
QuestionGenerate chart / graph in Visual Basic Pin
mariap11-Mar-08 12:45
mariap11-Mar-08 12:45 
GeneralRe: Generate chart / graph in Visual Basic Pin
Paul Conrad21-Mar-08 9:39
professionalPaul Conrad21-Mar-08 9:39 
GeneralRe: Generate chart / graph in Visual Basic Pin
mariap21-Mar-08 11:37
mariap21-Mar-08 11:37 
Generalwaiter !!! Pin
Assaf8211-Mar-08 11:15
Assaf8211-Mar-08 11:15 
GeneralRe: waiter !!! Pin
Luc Pattyn11-Mar-08 15:38
sitebuilderLuc Pattyn11-Mar-08 15:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.