我应该在以下代码中进行Wat更改,以便在Oracle Db中使用而不是Ms Sql [英] Wat Changes Should I Made In The Following Code For Using In Oracle Db Instead Of Ms Sql

查看:48
本文介绍了我应该在以下代码中进行Wat更改,以便在Oracle Db中使用而不是Ms Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个领域的新手,而dis是一个基本的问题。请帮助。

Hi I am new in this field and dis is kind of a basic question.kindly help.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;

    public class Db
    {

        public static string ConnectionString()
        {
            bool mssql = !SqLiteFound();
            if (mssql)
            {
                return ConfigurationManager.ConnectionStrings["daypilot"].ConnectionString;
            }

            if (HttpContext.Current.Session["cs"] as string == null)
            {
                HttpContext.Current.Session["cs"] = GetNew();
            }

            return (string)HttpContext.Current.Session["cs"];

        }

        public static DbProviderFactory Factory()
        {
            return DbProviderFactories.GetFactory(FactoryName());
        }

        public static string FactoryName()
        {
            if (SqLiteFound())
            {
                return "System.Data.SQLite";
            }
            return "System.Data.SqlClient";
        }

        public static string IdentityCommand()
        {
            switch (FactoryName())
            {
                case "System.Data.SQLite":
                    return "select last_insert_rowid();";
                case "System.Data.SqlClient":
                    return "select @@identity;";
                default:
                    throw new NotSupportedException("Unsupported DB factory.");
            }
        }


        private static string GetNew()
        {
            string today = DateTime.Today.ToString("yyyy-MM-dd");
            string guid = Guid.NewGuid().ToString();
            string dir = HttpContext.Current.Server.MapPath("~/App_Data/session/" + today + "/");
            string master = HttpContext.Current.Server.MapPath("~/App_Data/daypilot.sqlite");
            string path = dir + guid;

            Directory.CreateDirectory(dir);
            File.Copy(master, path);

            return String.Format("Data Source={0}", path);
        }

        private static bool SqLiteFound()
        {
            string path = HttpContext.Current.Server.MapPath("~/bin/System.Data.SQLite.dll");
            return File.Exists(path);
        }

    }

推荐答案

请阅读我对该问题的评论。



请参考:

如何:使用SqlDataSource控件连接到Oracle数据库 [ ^ ]

使用适用于Oracle的.NET Framework数据提供程序来提高.NET应用程序性能 [ ^ ]
Please, read my comment to the question.

Please, refer this:
How to: Connect to an Oracle Database Using the SqlDataSource Control[^]
Using .NET Framework Data Provider for Oracle to Improve .NET Application Performance[^]


这篇关于我应该在以下代码中进行Wat更改,以便在Oracle Db中使用而不是Ms Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆