Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving contents of a TextBox

Posted on 2004-10-14
3
Medium Priority
?
228 Views
Last Modified: 2010-04-23
Hello everyone,

I have a small problem that maybe somone could help me with. I have an app that lets me input raw sql commands and load sql scripts but what I would like to do and cannot accomplish is get the savefiledialog to save the contents of the textbox to a .sql file so I can use it later. I am able to get the box to open and I can get it to write the file but am not able to give a filename or get it to write the contents of the box

Thanks for the help.
Joe
0
Comment
Question by:JoeDW
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 1400 total points
ID: 12308811
Hi JoeDW,


            Dim fWriter As StreamWriter
            Dim sLine As String
            Dim sFileName As String
            Dim dresult As System.Windows.Forms.DialogResult

            dlgSave.CheckFileExists = False
            dlgSave.AddExtension = True
            dlgSave.Filter = "Excel Spreadsheet|*.xls|Comma Separated Values|*.csv|Tab Separated Values|*.tsv|Fixed Layout|*.txt|All Files|*.*"
            dresult = dlgSave.ShowDialog()

            Me.Refresh()

            If (dlgSave.FileName <> "") And (dresult = DialogResult.OK) Then

                sFileName = dlgSave.FileName

                fWriter = File.CreateText(sFileName)
                sLine = txtSQL.Text
                fWriter.WriteLine(sLine)
                fWriter.Flush()
                fWriter.Close()
            End IF


Cheers!
0
 
LVL 1

Author Comment

by:JoeDW
ID: 12308867
sweet, that worked flawlessly!! Just had to change the txtSQL to the name of the textbox and it worked perfect. Thanks a million. Here is an added 100 points for the quick reply.

Awesome!
0
 
LVL 18

Expert Comment

by:mdougan
ID: 12308971
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question