Hi,
I have the problem that the textfile did not appear after I saved it at my document, dekstop and other existing folder or new folder that created by user.Currently, it is only can be saved at C and D.
Below is the summary:
first:i want to call the value at database mssql server 2005
second:i want to save or export it to the textfile
third:the text file can be save at any location such as c,d,my document, new folder and any folder.
Here my code:
Private Sub savingFile()
sd.CreatePrompt = False
sd.FileName = lblName.Text
sd.InitialDirectory = "C:\"
sd.Title = "Save text Files"
sd.Filter = "Text File|*.txt"
If sd.ShowDialog() = DialogResult.OK Then
Console.WriteLine(sd.FileName)
exportProcedure(sd.FileName)
MsgBox("The data have been saved as text file.")
Else
MsgBox("You are not save as text file.")
End If
End Sub
Private Sub exportProcedure(ByVal fileName)
Try
Dim bcpCommand As String
bcpCommand = "Select Id,productcode, desc, Exclusion,
BrandName, CostPrice, "& _
"from " & DbName & ".dbo.tblWare " & _
"Where e.Id = '" & lblId.Text & "'"
Shell("bcp " + """" + bcpCommand + """" + " queryout " & _
"" & fileName & " -S " & sServer & " -U sa -P Sun -c -t ^ -r \n ",
vbHide)
Catch ex As Exception
MsgBox(ex.Message())
End Try
End Sub
TQ.