Dim conn As MySqlConnection = New MySqlConnection("server=******;Port=3306;database=*****;user id=root;password=******;")
conn.Open()
Dim query As String
query = " SELECT Street, HouseNum, Town, CustomerID, PostCode FROM customer WHERE CustomerID = " & Me.custidtext.Text & ""
Dim cmd As MySqlCommand = New MySqlCommand(query, conn)
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
reader.Read()
Dim oWord As Word.Application
Dim oDoc As Word.Document
'Start Word and Open document template
oWord = CType(CreateObject("Word.Application"), Word.Application)
oWord.Visible = False
oDoc = oWord.Documents.Add("C:\Visual Studio 2008\Projects\form.doc")
oDoc.Bookmarks("customer").Range.Text = Me.customertext.Text
oDoc.Bookmarks("description").Range.Text = Me.problem.Text
oDoc.Bookmarks("address").Range.Text = reader("Street").ToString + " " + reader("HouseNum").ToString + vbCrLf + reader("Town").ToString
oDoc.Bookmarks("model").Range.Text = Me.model.Text
oDoc.Bookmarks("serial").Range.Text = Me.serial.Text
oDoc.Bookmarks("reportedat").Range.Text = CStr(Me.datesched.Value)
oDoc.Bookmarks("solution").Range.Text = Me.solution.Text
oDoc.Bookmarks("finished").Range.Text = CStr(Me.datecompleted.Value)
oDoc.Bookmarks("postcode").Range.Text = reader("PostCode").ToString
oDoc.Bookmarks("town").Range.Text = reader("Town").ToString
oDoc.Bookmarks("rmaid").Range.Text = Me.serviceidtext.Text
oDoc.Bookmarks("datenow").Range.Text = CStr(Date.Now)
oDoc.Bookmarks("technician").Range.Text = Me.technician.Text
oDoc.Bookmarks("technician").Range.Text = Me.techniciantext.Text
TEST.PrintPreviewControl1.Document = CType(oDoc, Printing.PrintDocument)
TEST.Show()