Click here to Skip to main content
15,908,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Windows Vista Purchase Pin
Christian Graus5-Feb-07 10:39
protectorChristian Graus5-Feb-07 10:39 
GeneralRe: Windows Vista Purchase Pin
Lucan075-Feb-07 11:58
Lucan075-Feb-07 11:58 
GeneralRe: Windows Vista Purchase Pin
sidkraft5-Feb-07 12:42
sidkraft5-Feb-07 12:42 
GeneralRe: Windows Vista Purchase Pin
Christian Graus5-Feb-07 13:41
protectorChristian Graus5-Feb-07 13:41 
GeneralRe: Windows Vista Purchase Pin
sidkraft5-Feb-07 14:58
sidkraft5-Feb-07 14:58 
QuestionByte data type in sql server Pin
manisghouri5-Feb-07 6:32
manisghouri5-Feb-07 6:32 
AnswerRe: Byte data type in sql server Pin
Colin Angus Mackay5-Feb-07 13:36
Colin Angus Mackay5-Feb-07 13:36 
GeneralRe: Byte data type in sql server Pin
manisghouri6-Feb-07 0:09
manisghouri6-Feb-07 0:09 
'To add document
'---------------
Private Function AddRequest(ByVal DocId As String, ByVal DocUSer As String _
, ByVal DocTitle As String, ByVal DocSubject As String, ByVal fileName As String) as Boolean

Dim cmd As New SqlCommand
Dim dr As SqlDataReader

' Read the Data into the Byte Array
Dim fStream As New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim DocData(fStream.Length) As Byte
fStream.Read(DocData, 0, CInt(fStream.Length))
fStream.Close()

With cmd
.CommandType = CommandType.StoredProcedure
.CommandText = "sp_AddDocument"
.Connection = Conn


Dim para1 As SqlParameter = .Parameters.Add("@DocId", SqlDbType.Varchar)
Dim para2 As SqlParameter = .Parameters.Add("@DocUser", SqlDbType.Int)
Dim para3 As SqlParameter = .Parameters.Add("@DocTitle", SqlDbType.VarChar)
Dim para4 As SqlParameter = .Parameters.Add("@DocData", SqlDbType.VarBinary)

para1.Value = DocId
para2.Value = DocUser
para3.Value = DocTitle
para4.Value = DocData

End With
Try

dr = cmdBrochureRequest.ExecuteReader
With dr
If .HasRows Then
While .Read
DocStatus = .Item(0)
isDone = True
End While
Else
MsgBox("No Document status retrieved", MsgBoxStyle.Critical, appTitle)
isDone = False
End If
End With

cmd.Parameters.Clear()
cmd = Nothing
dr.Close()





Catch ex As Exception
MsgBox("Error while inserting document into database:" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Critical, appTitle)
isDone = False
End Try


If isDone = True Then
isDone = AddRequestDetail(RequestId)
End If

Return isDone
End Function



'To read document
'---------------

Private Function OpenDocument(ByVal DocId as string)
Dim cmd As New SqlCommand
Dim dr As SqlDataReader

With cmd
.CommandText = "sp_GetDocument "
.CommandType = CommandType.StoredProcedure
.Connection = ConnPIMPS
.Parameters.AddWithValue("@DocId", DocId)
End With

Try
dr = cmd.ExecuteReader

dr.Read()
Dim FileData(dr.GetBytes(0, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
dr.GetBytes(0, 0, FileData, 0, FileData.Length)

DisplayDocument(FileData)
dr.close
Catch ex As Exception
MsgBox("Error while opening document :" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Critical, AppTitle)
Exit function
End Try


Private Sub DisplayDocument(ByVal arrInput() As Byte)
Dim i As Integer
Dim sOutput As New StringBuilder(arrInput.Length)

For i = 0 To arrInput.Length - 1
If Not CType(arrInput(i), Byte).ToString = 0 Then
sOutput.Append(Chr(arrInput(i)))
End If
Next
RichTextBox1.text = sOutput.ToString()
End Sub


Do you think it is what i required to save word document in sql server table,

regards

Nas
QuestionFill color on data report Pin
Acer36205-Feb-07 6:03
Acer36205-Feb-07 6:03 
QuestionComboBox Help Pin
Jason Baggett5-Feb-07 5:49
Jason Baggett5-Feb-07 5:49 
AnswerRe: ComboBox Help Pin
nlarson115-Feb-07 7:29
nlarson115-Feb-07 7:29 
GeneralRe: ComboBox Help Pin
Jason Baggett5-Feb-07 7:40
Jason Baggett5-Feb-07 7:40 
GeneralRe: ComboBox Help Pin
nlarson115-Feb-07 7:51
nlarson115-Feb-07 7:51 
QuestionDatagridview Rowheaderselect Pin
Nikila Venkat5-Feb-07 5:20
Nikila Venkat5-Feb-07 5:20 
Questioncreating a playlist Pin
jady845-Feb-07 5:09
jady845-Feb-07 5:09 
Questiona problem in array in vb.net Pin
Hasan Jaffal5-Feb-07 3:55
Hasan Jaffal5-Feb-07 3:55 
QuestionRe: a problem in array in vb.net Pin
Kschuler5-Feb-07 5:19
Kschuler5-Feb-07 5:19 
AnswerRe: a problem in array in vb.net Pin
Hasan Jaffal5-Feb-07 5:23
Hasan Jaffal5-Feb-07 5:23 
AnswerRe: a problem in array in vb.net Pin
Kschuler5-Feb-07 5:39
Kschuler5-Feb-07 5:39 
AnswerRe: a problem in array in vb.net Pin
nlarson115-Feb-07 5:35
nlarson115-Feb-07 5:35 
GeneralRe: a problem in array in vb.net Pin
Hasan Jaffal5-Feb-07 12:00
Hasan Jaffal5-Feb-07 12:00 
GeneralRe: a problem in array in vb.net Pin
nlarson115-Feb-07 12:22
nlarson115-Feb-07 12:22 
GeneralRe: a problem in array in vb.net Pin
Hasan Jaffal5-Feb-07 12:53
Hasan Jaffal5-Feb-07 12:53 
GeneralRe: a problem in array in vb.net Pin
TwoFaced5-Feb-07 15:29
TwoFaced5-Feb-07 15:29 
QuestionGlobal Dataset Pin
liona5-Feb-07 2:42
liona5-Feb-07 2:42 

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.