473,320 Members | 1,950 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,320 software developers and data experts.

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 19 '05 #1
3 1066
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.***@manyworlds.com> wrote in message
news:u9*************@TK2MSFTNGP15.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 19 '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.***@manyworlds.com> wrote in message
news:u9***************@TK2MSFTNGP15.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 19 '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="Oracle" Then
Return "SELECT fld1 FROM table1 WHERE rownum=1"
End If
End Sub

--
Joe Fallon

"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:u9***************@TK2MSFTNGP15.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 19 '05 #4

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

Similar topics

6
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...
3
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...
5
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...
2
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...
5
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...
1
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...
2
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...
11
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...
4
by: Keith Patrick | last post by:
I have an app where a Shockwave splash animation starts off my app and then sets its parent iframe's src to the value of a default page "BasicReports". BasicReports has a link to another report...
9
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.