Click here to Skip to main content
16,014,677 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Need help with type Pin
Luc Pattyn22-Jun-10 7:26
sitebuilderLuc Pattyn22-Jun-10 7:26 
GeneralRe: Need help with type Pin
User 584223727-Jun-10 1:00
User 584223727-Jun-10 1:00 
QuestionWhen Is The Backgroundworker Really Completed? Pin
Sonhospa21-Jun-10 8:05
Sonhospa21-Jun-10 8:05 
AnswerRe: When Is The Backgroundworker Really Completed? Pin
Luc Pattyn21-Jun-10 8:30
sitebuilderLuc Pattyn21-Jun-10 8:30 
AnswerRe: When Is The Backgroundworker Really Completed? Pin
Аslam Iqbal12-Jul-10 12:45
professionalАslam Iqbal12-Jul-10 12:45 
GeneralRe: When Is The Backgroundworker Really Completed? Pin
Sonhospa13-Jul-10 11:06
Sonhospa13-Jul-10 11:06 
GeneralRe: When Is The Backgroundworker Really Completed? Pin
Аslam Iqbal14-Jul-10 8:08
professionalАslam Iqbal14-Jul-10 8:08 
QuestionStoring and reading Word documents in SQL Pin
Jason Skala20-Jun-10 17:46
Jason Skala20-Jun-10 17:46 
I am trying to store a word document to an image field in SQL. I get the file to send to SQL using the first code below. The problem is that when I try to load the field into a Word document using the second code, it is corrupted. I am thinking that it has something to do with encoding, but not sure. Can someone please help? Thanks in advance.


Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Title = "Save File to SQL"

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
myStream = openFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then

Dim MyData(myStream.Length) As Byte
myStream.Read(MyData, 0, (myStream.Length))
Me.TowerTableAdapter.Add_LOTO(MyData, Me.Monsanto_Equip_NoTextBox.Text.ToString)
Me.TextBox3.Text = myStream.Length
End If
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally
If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try
End If


End Sub


Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim axWord As Word.Application
axWord = New Word.Application
axWord.Visible = True
Dim axDoc As Word.Document
axDoc = axWord.Documents.Add
Dim strText As String
strText = axDoc.Paragraphs(1).Range.Text

Dim conn = New SqlConnection(My.Settings.Maintenance_ManagementSQLConnectionString)
Dim EQ As String = Me.Monsanto_Equip_NoTextBox.Text.ToString
Dim AreaCMD As New SqlCommand()
AreaCMD.Connection = conn
AreaCMD.CommandText = "SELECT LOTO FROM [tower]where [monsanto equip no] = '" & EQ & "'"
conn.Open()

Dim AR As SqlDataReader = AreaCMD.ExecuteReader(CommandBehavior.SequentialAccess)

While AR.Read()
Dim binaryStream As SqlBinary = AR.GetSqlBinary(0)

Dim test As String = System.Text.Encoding.Unicode.GetString(binaryStream)
axDoc.Paragraphs(1).Range.Text = test.ToString

End While

conn.Close()
End Sub
AnswerRe: Storing and reading Word documents in SQL Pin
Luc Pattyn20-Jun-10 18:15
sitebuilderLuc Pattyn20-Jun-10 18:15 
GeneralRe: Storing and reading Word documents in SQL Pin
Jason Skala20-Jun-10 18:36
Jason Skala20-Jun-10 18:36 
GeneralRe: Storing and reading Word documents in SQL Pin
Luc Pattyn20-Jun-10 19:13
sitebuilderLuc Pattyn20-Jun-10 19:13 
GeneralRe: Storing and reading Word documents in SQL Pin
Jason Skala20-Jun-10 20:59
Jason Skala20-Jun-10 20:59 
GeneralRe: Storing and reading Word documents in SQL Pin
DaveAuld20-Jun-10 22:39
professionalDaveAuld20-Jun-10 22:39 
GeneralRe: Storing and reading Word documents in SQL Pin
Luc Pattyn21-Jun-10 2:19
sitebuilderLuc Pattyn21-Jun-10 2:19 
QuestionNeed help with Image Pin
jaygalway211620-Jun-10 17:43
jaygalway211620-Jun-10 17:43 
AnswerRe: Need help with Image Pin
Luc Pattyn20-Jun-10 18:06
sitebuilderLuc Pattyn20-Jun-10 18:06 
GeneralRe: Need help with Image Pin
jaygalway211620-Jun-10 18:44
jaygalway211620-Jun-10 18:44 
GeneralRe: Need help with Image Pin
Luc Pattyn20-Jun-10 19:04
sitebuilderLuc Pattyn20-Jun-10 19:04 
QuestionVisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
QuickBooksDev19-Jun-10 1:19
QuickBooksDev19-Jun-10 1:19 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
AnnieMacD19-Jun-10 1:26
AnnieMacD19-Jun-10 1:26 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
Luc Pattyn19-Jun-10 1:58
sitebuilderLuc Pattyn19-Jun-10 1:58 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
DaveAuld19-Jun-10 4:38
professionalDaveAuld19-Jun-10 4:38 
QuestionCoalesce -- Any suggestions on how to improve this? Pin
Gregory Gadow18-Jun-10 8:08
Gregory Gadow18-Jun-10 8:08 
AnswerRe: Coalesce -- Any suggestions on how to improve this? Pin
rhuiden18-Jun-10 10:26
rhuiden18-Jun-10 10:26 
QuestionSingle Sign on Pin
berba18-Jun-10 2:59
berba18-Jun-10 2:59 

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.