私はこれを理解しようとして苦労してきました。特定の機関と関係のある特定のデータを選択するための SQL クエリを作成しました。MySQL Workbench でテストしたところ、SQL クエリは問題なく動作しましたが、そのデータを VB.NET から Word ドキュメントにエクスポートしようとすると、文字通り SQL が出力されます。
以下は私のコードです:
Dim sqlAdapter As New MySqlDataAdapter
Dim sqlCommand As New MySqlCommand
Dim sqlTable As New DataTable
Dim sqlFundText As String = "select mutual_Fund_name, concat(contact_first_name,' ',contact_last_name) from mutual_fund mf, contact c, mutual_fund_has_contact mfhc, institution i, institution_has_mutual_Fund ihmf where mf.mutual_fund_id = mfhc.mutual_fund_id and c.contact_id = mfhc.contact_id and ihmf.mutual_fund_id = mf.mutual_fund_id and i.institution_id = ihmf.institution_id and i.institution_name ='" & InstitutionNameTextBox.Text & "' order by mutual_fund_name;"
With sqlCommand
.CommandText = sqlFundText
.Connection = sConnection
End With
With sqlAdapter
.SelectCommand = sqlCommand
.Fill(sqlTable)
End With
oPara9 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
With oPara9
.Range.Font.Bold = False
.Range.Text = sqlFundText
.Range.Font.Size = 10
.Format.SpaceAfter = 5
.Range.InsertParagraphAfter()
End With
結果は次のとおりです。
ご覧のとおり、SQL ステートメントが出力されます。
私はそれが関係していることを知っています
.Range.Text = sqlFundText
私はそれを修正する方法がわかりません。誰でもこれを修正する正しい方法を教えてもらえますか?