Click here to Skip to main content
15,901,284 members
Home / Discussions / C#
   

C#

 
AnswerRe: table web server control Pin
gauthee8-Feb-07 0:43
gauthee8-Feb-07 0:43 
GeneralRe: table web server control Pin
acodman8-Feb-07 0:45
acodman8-Feb-07 0:45 
GeneralRe: table web server control Pin
gauthee8-Feb-07 1:18
gauthee8-Feb-07 1:18 
Questionmachine.config file Pin
Ananthalvan7-Feb-07 23:37
Ananthalvan7-Feb-07 23:37 
QuestionObject-Relational Mapping Tool to support multiple DB require [modified] Pin
Niraj Parikh7-Feb-07 23:14
Niraj Parikh7-Feb-07 23:14 
AnswerRe: Object-Relational Mapping Tool to support multiple DB require Pin
m@u8-Feb-07 0:10
m@u8-Feb-07 0:10 
GeneralRe: Object-Relational Mapping Tool to support multiple DB require [modified] Pin
Niraj Parikh8-Feb-07 0:37
Niraj Parikh8-Feb-07 0:37 
GeneralRe: Object-Relational Mapping Tool to support multiple DB require Pin
m@u8-Feb-07 2:55
m@u8-Feb-07 2:55 
Hi
i can't say that xpo is definitely the right choice for this, but what i can say is that i work pretty often with binding variables in oracle. there, thet parameter type is, (of course Smile | :) ), called OracleParameter and has also a property called Size, which i have never assigned anything to and it always worked fine yet..

However, if you look at System Data, you find the basic Class of all Connections called IdbConnection. so theoretically you could have one class which creates depending on what dbType you want to connect an SQLConnection or a MySQLConnection or whatever. to the other Classes which use the connection, you simply pass it as an IdbConection instance.

IdbConnection implements a function called CreateCommand() which passes you the basic-Class of all DBCommands: an IdbCommand. so you get an SQLCommand or whatever wrapped in an IdbCommand and you can set the CommandText and all the other things you need and you're still db-Independent.

that means, you could do it even without XPO because the .net System.Data - Namespace gives you theoretically everything you need to create a DB-Independent Application.

try the following:

let's say you implement a Connect() Method like this:
<br />
private IdbConnection Connect(string User, string Pass, string Connection, string Schema, string DBType)<br />
{<br />
    IdbConnection RetVal = null;<br />
    switch(DBType.ToLower())<br />
    {<br />
        case "oracle":<br />
        {<br />
            RetVal = new OracleConnection(User, Pass, Connection);<br />
            IdbCommand cmd = RetVal.CreateCommand();<br />
            cmd.Connection = RetVal;<br />
            cmd.CommandText = string.Format("Alter Session set Current_Schema = \"{0}\"",Schema.ToUpper());<br />
            cmd.ExecuteNonQuery();<br />
            break;<br />
        }<br />
        case "sql":<br />
        {<br />
            //Connect to SQL Here<br />
        }<br />
        case "whatever":<br />
        {<br />
           // Connect to whatever here..<br />
        }<br />
    }<br />
}<br />

now you have a nice little Method that gives you a DataBase Independend Connection.
you can Create and Execute Commands on it without even knowing what Kind of DB your sitting on.
if you want to execute a StoredProcedure with 2 Parameters you simply say:
<br />
private void ExecuteSomeSP()<br />
{<br />
    IdbCommand cmd = myConnection.CreateCommand();<br />
    cmd.CommandText = "Execute Blah(:1,:2)";<br />
    idbParameter Param = cmd.CreateParameter();<br />
    Param.DbType = DbType.String;<br />
    Param.Direction = ParameterDirection.Input;<br />
    Param.Value = "Kaboom!";<br />
    Param = cmd.CreateParameter();<br />
    Param.DbType = DbType.Int64;<br />
    Param.Direction = ParameterDirection.Input;<br />
    Param.Value = (long)250;<br />
    cmd.Connection = myConnection;<br />
    cmd.ExecuteNonQuery();<br />
}<br />


so you see, by only accessing the System.Data Namespace you can theoretically create Database Independent Applications. I guess XPO will just wrap it to make it more comfortable to use, but basically it works without installing any third-party - Product.

I hope this helps

greets
M@u
GeneralRe: Object-Relational Mapping Tool to support multiple DB require Pin
Niraj Parikh8-Feb-07 3:42
Niraj Parikh8-Feb-07 3:42 
GeneralRe: Object-Relational Mapping Tool to support multiple DB require Pin
m@u8-Feb-07 4:57
m@u8-Feb-07 4:57 
Questionaccess to member of other method? Pin
jens1234567-Feb-07 23:13
jens1234567-Feb-07 23:13 
AnswerRe: access to member of other method? Pin
Martin#7-Feb-07 23:20
Martin#7-Feb-07 23:20 
GeneralRe: access to member of other method? Pin
jens1234567-Feb-07 23:50
jens1234567-Feb-07 23:50 
GeneralRe: access to member of other method? Pin
Martin#7-Feb-07 23:51
Martin#7-Feb-07 23:51 
QuestionConvert string to Enumeration Pin
babutkchn7-Feb-07 23:10
babutkchn7-Feb-07 23:10 
AnswerRe: Convert string to Enumeration Pin
Stefan Troschuetz7-Feb-07 23:14
Stefan Troschuetz7-Feb-07 23:14 
AnswerRe: Convert string to Enumeration Pin
Martin#7-Feb-07 23:26
Martin#7-Feb-07 23:26 
GeneralRe: Convert string to Enumeration Pin
babutkchn8-Feb-07 5:13
babutkchn8-Feb-07 5:13 
GeneralRe: Convert string to Enumeration Pin
Martin#8-Feb-07 5:15
Martin#8-Feb-07 5:15 
QuestionC# with sounds Pin
Ahmed Fathy7-Feb-07 21:57
Ahmed Fathy7-Feb-07 21:57 
AnswerRe: C# with sounds Pin
Christian Graus7-Feb-07 22:13
protectorChristian Graus7-Feb-07 22:13 
AnswerRe: C# with sounds Pin
aSarafian7-Feb-07 23:24
aSarafian7-Feb-07 23:24 
GeneralRe: C# with sounds Pin
Christian Graus7-Feb-07 23:45
protectorChristian Graus7-Feb-07 23:45 
GeneralRe: C# with sounds Pin
aSarafian8-Feb-07 0:34
aSarafian8-Feb-07 0:34 
GeneralRe: C# with sounds Pin
aSarafian8-Feb-07 2:57
aSarafian8-Feb-07 2:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.