473,788 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A way to transfer a query string for SQL Server to one for another database?

Hi:

If I have a query string for retrieving data from SQL Server database, is
there a way to transfer it to a query string for retrieving data from Oracle
or any other database like mySQL...? I mean by a program. I am working on
C#.

Thanks

Q.
Nov 16 '05 #1
3 1742
SQL is a standards language and therefore you should be able to use the same
query on any relational database, assuming you are not using any MS
proprietary extensions. All you have to do is to use the SqlCommand object
on a different IConnection object.

For instance, "select * from myTable" should work for all database.
"Quentin Huo" <q.***@manyworl ds.com> wrote in message
news:u9******** *****@TK2MSFTNG P15.phx.gbl...
Hi:

If I have a query string for retrieving data from SQL Server database, is
there a way to transfer it to a query string for retrieving data from Oracle or any other database like mySQL...? I mean by a program. I am working on
C#.

Thanks

Q.

Nov 16 '05 #2
If you're using the OleDb or Odbc classes instead of the Sql classes, then
you can use the same code and simply change the connection strings for
different database types. Your SQL needs to be compatible with all of the
databases, though. For example, you can't use SQL Server specific functions
in your query.

Pete
"Quentin Huo" <q.***@manyworl ds.com> wrote in message
news:u9******** *******@TK2MSFT NGP15.phx.gbl.. .
Hi:

If I have a query string for retrieving data from SQL Server database, is
there a way to transfer it to a query string for retrieving data from Oracle or any other database like mySQL...? I mean by a program. I am working on
C#.

Thanks

Q.

Nov 16 '05 #3
If you store your query string in a Shared method of a class you can
retrieve it by the method name (and use any parameters you might need.). You
could also pass in the DBtype (or read it from config) and the return a
different string from the same method for the other DB type. If the syntax
is identical you just return the same string.

e.g.

Public Shared Function GetMySQL() As String
Return "SELECT fld1 FROM table1"
End Sub

Public Shared Function GetMySpecialSQL (DBType As String) As String
If DBType="SQL Server" Then
Return "SELECT Top1 fld1 FROM table1"
ElseIfDBType="O racle" Then
Return "SELECT fld1 FROM table1 WHERE rownum=1"
End If
End Sub

--
Joe Fallon

"Quentin Huo" <q.***@manyworl ds.com> wrote in message
news:u9******** *******@TK2MSFT NGP15.phx.gbl.. .
Hi:

If I have a query string for retrieving data from SQL Server database, is
there a way to transfer it to a query string for retrieving data from
Oracle or any other database like mySQL...? I mean by a program. I am
working on C#.

Thanks

Q.

Nov 16 '05 #4

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

Similar topics

6
2240
by: StephenMcC | last post by:
Hi All, Got a quick query in relation to the Server.Transfer method available in IIS 5+/ASP. I've got an issue where I want to take a portion of an online app and extract this out into a web site on its own, so I will end up having two web sites. This planned to aid problems we've been having with performance, as if the portion (which is an app in its own right) has problems we then have to restart the whole site and so bring everything...
5
7409
by: Tom | last post by:
Hi I am trying to transfer to a different .ASPX page using Server.Transfer. However, I get the following error: "Error executing child request for .aspx." Anyone know why? Thanks for help.
2
1648
by: Jeremy | last post by:
I'm having some problems with using Server.Transfer and I am hoping somebody can help me. Page 1 has a datagrid, Page 2 has a form. If a user goes to page 1 and selects something out of the datagrid I want to transfer the value of that records item number in the grid over to page 2. I use the passed number to retrieve data from a database and populate the form.
5
7829
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user to the Item page "ViewItem.aspx" with a simple : Server.Transfer("ViewItem.aspx"); I'd like to pass another HTTP parameter so that in the "ViewItem.aspx" page,
1
3496
by: Victor Song | last post by:
Hi We are trying to stream a file using server.transfer rather than response.redirect. We have it working for IIS 5.0 but IIS 6.0 refusing to let us transfer the file. If we do the less efficient prompt/response technique to the browser both work fine. We found this article that was only slightly appicable (ms-help://MS.MSDNQTR.2004APR.1033/enu_kbiis/iis/326965.ht kb 326965 ) but since csv is already a defined mime type this shouldn't...
2
3380
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings for the web site are held in a database and all the labels, buttons etc are populated at run time in the Page_Load handler. The retreval of the strings from the database is all
11
6045
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it falls into an infinite loop and later a StackOverflow Exception. I need to do this and not a Response.Redirect or a transfer with the bool in false. My problem is that this KB is saying that this problem should be solved with ServicePack 1 of...
3
1081
by: Quentin Huo | last post by:
Hi: If I have a query string for retrieving data from SQL Server database, is there a way to transfer it to a query string for retrieving data from Oracle or any other database like mySQL...? I mean by a program. I am working on C#. Thanks Q.
9
1540
by: senfo | last post by:
In my not so humble opinion, Server.Transfer() looks good on paper, but I have yet to come across a use for it that couldn't be accomplished better another way. When it comes down to it, I really dislike the method because, at least at my company, it leads to bad designs. It also further irritates end users because it breaks the back button. I really wish the Server.Transfer() method would go away so people would stop using it. What...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.