473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Save SQL Script into Resources

Hi,

Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?

Thanks,
Nov 20 '05 #1
10 2931
Cor
Hi Shai
Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?


Why not,

Or do you mean what is the best way, I think there is no best way, that
depends in what kind of environment you want to use it.

If you tell that a little more, than maybe we can help you?

Cor
Nov 20 '05 #2
"Shai Goldberg" <gs***@shamir.co.il> schrieb

Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?

http://msdn.microsoft.com/library/en...gResources.asp
http://msdn.microsoft.com/library/en...gresources.asp
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
* "Shai Goldberg" <gs***@shamir.co.il> scripsit:
Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?


Add the file to the project, set its 'Build Action' to 'Embedded
Resource', then:

\\\
Imports System.IO
..
..
..
Dim f As Stream =
System.Reflection.Assembly.GetEntryAssembly().GetM anifestResourceStream( _
"<Name of the root namespace>.test.txt" _
)
Dim st As New StreamReader(f), s As String
s = st.ReadToEnd()
MsgBox(s)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Hi,

I need to add a text file into a source file and to be
able to read it during run time using VB.NET

I want to know if there is a way to do so using the
VS.NET IDE and VB.NET that is to insert into a source
file a bunch of text lines that I can read into a string
during run time.

Thanks,
-----Original Message-----
Hi Shai
Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?
Why not,

Or do you mean what is the best way, I think there is no

best way, thatdepends in what kind of environment you want to use it.

If you tell that a little more, than maybe we can help you?
Cor
.

Nov 20 '05 #5
Thanks for the answer but it didn't help me, maybe I just
didn't understand, but I need to load a lot of lines and
not only one single line.

Regards,

-----Original Message-----
"Shai Goldberg" <gs***@shamir.co.il> schrieb

Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?

http://msdn.microsoft.com/library/en-

us/vbcon/html/vboriUsingResources.asphttp://msdn.microsoft.com/library/en- us/cpguide/html/cpconcreatingusingresources.asp

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

Nov 20 '05 #6
Cor
Hi Shai,

I saw you did get some answers in this thread if that does not fit, message
again OK?

Cor

I need to add a text file into a source file and to be
able to read it during run time using VB.NET

I want to know if there is a way to do so using the
VS.NET IDE and VB.NET that is to insert into a source
file a bunch of text lines that I can read into a string
during run time.

Nov 20 '05 #7
"Shai Goldberg" <gs***@shamir.co.il> wrote in news:057201c3cd49$29ca5b20
$a*******@phx.gbl:
Hi,

Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?

Thanks,


Hi,

You can use streamreader function to read the sql text, and after that can
you make a split on 'GO'. after that can you execute the the different
parts in the script. (you can not execute the hole script including GO,
because it isnt allowed)

Thomas
Nov 20 '05 #8
Cor
Hi Shai,

I saw you other message, the most easiest way is to make a dataset,

I made some examples below. I did not make in the IDE so it is probably with
errors.

I think this wil fits your problem?

Cor

\\\\
dim ds as new dataset
if file.exist ("c:\test1\testxml.xml") then
ds.ReadXml("c:\testxml.xml", XmlReadMode.ReadSchema)
Dim dr As DataRow = ds.Tables(0).Rows.Find("mynumber")
if not dr Is Nothing Then
mySQLstring = dr.item("mySqlString").tostring
else
'errormessage
Else
'errormessage
End If
////
\\\\
To create this dataset is.
dim ds as new dataset
Dim dt As New DataTable("SqlStrings")
dt.Columns.Add(New DataColumn("mySqlStringnumber",
Type.GetType("System.Int32")))
dt.Columns.Add(New DataColumn("mySqlString", Type.GetType("System.String")))
Dim keys(0) As DataColumn
keys(0) = dt.Columns("mySqlStringnumber")
dt.PrimaryKey = keys
ds.Tables.Add(dt)
ds.WriteXml("c:\testxml.xml", XmlWriteMode.WriteSchema)
///
\\\
To add the rows you can use the normal dataset instructions for that
////
Nov 20 '05 #9
"Shai Goldberg" <gs***@shamir.co.il> schrieb
Thanks for the answer but it didn't help me, maybe I just
didn't understand, but I need to load a lot of lines and
not only one single line.


Resources are not limited to a single line.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10
Herfried hi,

I wanted to thank you for your solution, it was what I
was looking for!

I want also to thank all that tried to help me.

Regrads,
-----Original Message-----
* "Shai Goldberg" <gs***@shamir.co.il> scripsit:
Is there a way to store an SQL script into a resource
file, the script contains a lot of lines, and then to
read it during run-time into a string?
Add the file to the project, set its 'Build Action'

to 'EmbeddedResource', then:

\\\
Imports System.IO
..
..
..
Dim f As Stream =
System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream( _ "<Name of the root namespace>.test.txt" _
)
Dim st As New StreamReader(f), s As String
s = st.ReadToEnd()
MsgBox(s)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Asken | last post by:
Hello, i could not find information about extracting data by using *sql_query (for me mssql_query) and do that in a way that saves server memory. I usually use: $sql = "exec...
7
by: Rune Strand | last post by:
What would it take to create a Firefox extension that enables Python as a script language in the browser - just like Javascript? Is it at all possible? Are the hundred good reasons not to bother? ...
6
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of...
2
by: icedgar | last post by:
am using the following script in the BeforeUpdate area of a main form. Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String strMsg = "Do you wish to save your changes?" If...
0
by: ATS | last post by:
HOWTO Extract resources from .NEt User Control and save them to file. Please help, I have a .NET C# User Control (derrived from System.Windows.Forms.UserControl), and I want to embed into it...
7
by: gorkos | last post by:
Hi, I am two days trying to solve a problem with some pages, which i get through HTTPWebRequest. Error is that some pages need Script to be enabled. But how to do this in HTTPWebRequest class?
3
by: fiefie.niles | last post by:
I would like to save a web page to a file. When I do that, sometimes the saved web page does not look like the original web page. For example, when I save www.msn.com, it looks very different the...
4
by: Daniel Marious | last post by:
Hi, I'm looking for a .Net/COM component which would allow a .Net programmer with no streaming experience to be able to save online streams to local resources (files or to DB). I know that if...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.