473,398 Members | 2,393 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,398 software developers and data experts.

Encapsulating SQL code in .net

Hello,
I would like to completely encapsulate approximately 1000 lines of
SQL code in my vb.net web application. Setting the 1000 lines of SQL
code equal to a string seems inefficient. Setting the SQL code equal
to a string would be difficult because I would have to use numerous
underscores ( _ ) and plus signs ( + ). I also do not want to use
stored procedures for intellectual property / security reasons (I have
to give the client the SQL Server SA password). Can anyone please
tell me a good way of accomplishing this goal?

Thanks,
Billy
Jul 21 '05 #1
4 1412
Billy,

Consider loading script from file

HTH
Alex

"Billy Cormic" <bi**********@hotmail.com> wrote in message
news:dd**************************@posting.google.c om...
Hello,
I would like to completely encapsulate approximately 1000 lines of
SQL code in my vb.net web application. Setting the 1000 lines of SQL
code equal to a string seems inefficient. Setting the SQL code equal
to a string would be difficult because I would have to use numerous
underscores ( _ ) and plus signs ( + ). I also do not want to use
stored procedures for intellectual property / security reasons (I have
to give the client the SQL Server SA password). Can anyone please
tell me a good way of accomplishing this goal?

Thanks,
Billy

Jul 21 '05 #2
Billy,
In addition to the other comments.

Is this a single SQL Script or multiple SQL Scripts?

I would consider embedding a single SQL script as an embedded resource file
in my assembly. Or I would consider embedding multiple SQL scripts as
embedded resource strings in my assembly.

You can add an .sql file to your project, and set the "Build Action" on the
file properties (from Solution Explorer) as "Embedded Resource. Then you can
use System.Reflection.Assembly.GetManifestResourceStre am to read the SQL
Script from the assembly.

Alternatively you can add a .resx file to your project to hold multiple SQL
scripts. And use System.Resources.ResourceManager (or other classes in
System.Resources) to read the SQL script resource strings...

Hope this helps
Jay
"Billy Cormic" <bi**********@hotmail.com> wrote in message
news:dd**************************@posting.google.c om...
Hello,
I would like to completely encapsulate approximately 1000 lines of
SQL code in my vb.net web application. Setting the 1000 lines of SQL
code equal to a string seems inefficient. Setting the SQL code equal
to a string would be difficult because I would have to use numerous
underscores ( _ ) and plus signs ( + ). I also do not want to use
stored procedures for intellectual property / security reasons (I have
to give the client the SQL Server SA password). Can anyone please
tell me a good way of accomplishing this goal?

Thanks,
Billy

Jul 21 '05 #3
You may find this helpful http://www.knowdotnet.com/articles/ddl.html . I've
done it a few different ways in this article.

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Billy Cormic" <bi**********@hotmail.com> wrote in message
news:dd**************************@posting.google.c om...
Hello,
I would like to completely encapsulate approximately 1000 lines of
SQL code in my vb.net web application. Setting the 1000 lines of SQL
code equal to a string seems inefficient. Setting the SQL code equal
to a string would be difficult because I would have to use numerous
underscores ( _ ) and plus signs ( + ). I also do not want to use
stored procedures for intellectual property / security reasons (I have
to give the client the SQL Server SA password). Can anyone please
tell me a good way of accomplishing this goal?

Thanks,
Billy

Jul 21 '05 #4
Billy Cormic wrote:
Hello,
I would like to completely encapsulate approximately 1000 lines of
SQL code in my vb.net web application. Setting the 1000 lines of SQL
code equal to a string seems inefficient. Setting the SQL code equal
to a string would be difficult because I would have to use numerous
underscores ( _ ) and plus signs ( + ). I also do not want to use
stored procedures for intellectual property / security reasons (I have
to give the client the SQL Server SA password). Can anyone please
tell me a good way of accomplishing this goal?

Thanks,
Billy


You might want to consider breaking down your problem.

Why don't you create a class that has some of the properties and methods
appropriate to a SQL statement.

For example, (this is psuedo code-- you can flesh it out )

class SqlScript
{

public SqlString( string table,
string[] fields,
string where,
string order )

{

// set to local variables
}
public string buildStatement()
{

StringBuilder sb;
sb.Append("SELECT");

for each ( string str in fields)
{
sb.Append(str);
sb.Append(",");
}

sb.Append("FROM ");

// and so on... you get the idea
}
}
Jul 21 '05 #5

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

Similar topics

1
by: Greg Galloway | last post by:
Hi, Ive got an XML file thats rendered with an XSL. Ive also got a template in HTML and I want the content of the XML file to be displayed within this HTML template. However when I try to put...
2
by: Adie | last post by:
Hi, just looking for tips and ideas from the experienced. I wondered if you guys encapsulate the SqlDataReader so as to allow simpler code with less duplation, if so what does your code look like...
1
by: Phin | last post by:
Hi, I saw that a few people in the past have been getting the same error when a user tries to drill down (to a sub-report) on a crytal report with ASP.NET (but there was no solution posted): ...
4
by: Billy Cormic | last post by:
Hello, I would like to completely encapsulate approximately 1000 lines of SQL code in my vb.net web application. Setting the 1000 lines of SQL code equal to a string seems inefficient. Setting...
2
by: John Goche | last post by:
Hello, The class TRefByValue in the Symbian OS API encapsulates a reference inside a class so that it can be passed by value to functions. But why would we want this? After all, if a function...
0
bartonc
by: bartonc | last post by:
By encapsulating just a few fuctions from two library modules, we get a clear picture of what a digital filter looks like. Also, by splitting __init__ into two section, the filter's creation...
1
by: metaperl | last post by:
I have a series of scripts which retrieve files. None of these scripts should continue if the file to be retrieved already exists in the archive. Here is the code: if f in...
10
by: roberto | last post by:
I'm to deploy a .NET DLL which internally communicates with the WS. I don't want others to see internal complexity of the web service classes generated by "Add a Web reference" VS option. As a...
2
by: Immortal_Nephi | last post by:
Sometimes, programmers decide to create only one object. One object is used for a whole program. You can run two or more programs at the same time. Each program has a copy of its own object....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.