当前位置: 首页>>代码示例>>C#>>正文


C# OleDbConnectionStringBuilder.ContainsKey方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbConnectionStringBuilder.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbConnectionStringBuilder.ContainsKey方法的具体用法?C# OleDbConnectionStringBuilder.ContainsKey怎么用?C# OleDbConnectionStringBuilder.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbConnectionStringBuilder的用法示例。


在下文中一共展示了OleDbConnectionStringBuilder.ContainsKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReportData

        public static List<AvgSpeedReportItem> GetReportData()
        {
            string query =
@"WITH RankedLink AS (
		SELECT ROW_NUMBER() OVER (ORDER BY Link, SegEndC) [Number], *
		FROM dbo.Olaine_LINK_EVAL),
	MiddleLink AS (
		SELECT AVG(Number) [MiddleLink]
		FROM RankedLink
		GROUP BY Link),
	AvgSpeed AS (
		SELECT AVG(v__0_) [speed], Link
		FROM dbo.Olaine_LINK_EVAL
		GROUP BY Link)

SELECT RankedLink.Link, 0 [Lane], (SegStX + SegEndX)/2 [center.x], (SegStY + SegEndY)/2 [center.y], AvgSpeed.speed
FROM RankedLink
	JOIN MiddleLink ON RankedLink.Number=MiddleLink.MiddleLink
	JOIN AvgSpeed ON RankedLink.Link=AvgSpeed.Link";

            var list = new List<AvgSpeedReportItem>();

            try
            {
                var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
                if (sb.ContainsKey("Password"))
                {
                    using (var conn = new OleDbConnection(sb.ConnectionString))
                    {
                        conn.Open();
                        try
                        {
                            using (var reader = new OleDbCommand(query, conn).ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    list.Add(new AvgSpeedReportItem()
                                    {
                                        Link = reader.GetInt32(0),
                                        Lane = reader.GetInt32(1),
                                        Center = new Point(reader.GetDouble(2), reader.GetDouble(3)),
                                        AvgSpeed = reader.GetDouble(4)
                                    });
                                }
                            }
                        }
                        finally
                        {
                            conn.Close();
                        }
                    }
                }
            }
            catch { }

            return list;
        }
开发者ID:A-n-d-r-e-y,项目名称:VISLAB,代码行数:57,代码来源:Analyst.cs

示例2: DbConnectionFromConnectionString

        public static DbConnection DbConnectionFromConnectionString(string connectionString)
        {
            DbConnection connection = null;
            OleDbConnectionStringBuilder builder = new System.Data.OleDb.OleDbConnectionStringBuilder(connectionString);
            string provider = builder["Provider"].ToString();
            if (provider.StartsWith("MSDASQL"))
            {
                //Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=mysql2;SERVER=localhost;UID=root;DATABASE=sakila;PORT=3306";Initial Catalog=sakila
                //Provider=MSDASQL.1;Persist Security Info=True;Data Source=mysql;Initial Catalog=sakila
                //Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=brCRM;DBQ=C:\tem\adb.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"

                //Extract the real ODBC connection string...to be able to use the OdbcConnection
                string odbcConnectionString = "";
                if (builder.ContainsKey("Extended Properties")) odbcConnectionString = builder["Extended Properties"].ToString();
                else if (builder.ContainsKey("Data Source") && !string.IsNullOrEmpty(builder["Data Source"].ToString())) odbcConnectionString = "DSN=" + builder["Data Source"].ToString();
                if (odbcConnectionString != "" && builder.ContainsKey("Initial Catalog")) odbcConnectionString += ";DATABASE=" + builder["Initial Catalog"].ToString();
                if (odbcConnectionString != "" && builder.ContainsKey("User ID")) odbcConnectionString += ";UID=" + builder["User ID"].ToString();
                if (odbcConnectionString != "" && builder.ContainsKey("Password")) odbcConnectionString += ";PWD=" + builder["Password"].ToString();

                connection = new OdbcConnection(odbcConnectionString);
            }
            else
            {
                connection = new OleDbConnection(connectionString);
            }
            return connection;
        }
开发者ID:cnark,项目名称:Seal-Report,代码行数:27,代码来源:Helper.cs

示例3: btnUseSqlCmd_Click

        private void btnUseSqlCmd_Click(object sender, EventArgs e)
        {
            string argument = "";
            OleDbConnectionStringBuilder osb = new OleDbConnectionStringBuilder(this.ConnStr);
            string server = osb["Data Source"].ToString();
            string catalog = osb["Initial Catalog"].ToString();
            if (osb.ContainsKey("integrated security"))
            {
                string argumentFormat = "sqlcmd -S \"{0}\" -d \"{1}\" -E -i  \"{2}\"";
                argument = string.Format(argumentFormat, server, catalog, txtSQLFileName.Text);
            }
            else
            {
                string argumentFormat = "sqlcmd -S \"{0}\" -U \"{2}\" -P \"{3}\" -d \"{1}\" -i  \"{4}\"";

                string user = osb["User ID"].ToString();
                string password = osb["Password"].ToString();

                argument = string.Format(argumentFormat, server, catalog, user, password, txtSQLFileName.Text);
            }

            this.ShowMessage("[{0}]", argument);
            this.ShowMessage("命令执行中。。。。(请等待完成提示。。。。)");

            Process p = new Process();
            p.EnableRaisingEvents = true;

            p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
            p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);

            p.Exited += new EventHandler(p_Exited);
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.Arguments = "/c " + argument;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            start = DateTime.Now;
            p.Start();
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();
        }
开发者ID:piaolingzxh,项目名称:Justin,代码行数:43,代码来源:SqlExecuterCtrl.cs

示例4: HasPassword

 /// <summary>
 /// returns value to indicate if connection string has a password associated with it
 /// </summary>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 protected virtual bool HasPassword(string connectionString)
 {
     if (!string.IsNullOrEmpty(connectionString))
     {
         OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(this.connectionString);
         return builder.ContainsKey("Jet OLEDB:Database Password");
     }
     else
     {
         return false;
     }
 }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:17,代码来源:OleDbDatabase.cs

示例5: GetSegments

        public static List<Line> GetSegments()
        {
            string query = @"select Link, Lane, SegStX, SegStY, SegEndX, SegEndY from dbo.Olaine_LINK_EVAL";

            var list = new List<Line>();

            var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
            if (sb.ContainsKey("Password"))
            {
                using (var conn = new OleDbConnection(sb.ConnectionString))
                {
                    conn.Open();
                    using (var reader = new OleDbCommand(query, conn).ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            list.Add(new Line()
                            {
                                X1 = reader.GetDouble(2),
                                Y1 = reader.GetDouble(3),
                                X2 = reader.GetDouble(4),
                                Y2 = reader.GetDouble(5),
                                Stroke = Brushes.Red
                            });
                        }
                    }
                }
            }

            return list;
        }
开发者ID:A-n-d-r-e-y,项目名称:VISLAB,代码行数:31,代码来源:Analyst.cs

示例6: GetPoints

        public static List<Ellipse> GetPoints(int size)
        {
            string query = @"select Link, Lane, SegStX, SegStY, SegEndX, SegEndY from dbo.Olaine_LINK_EVAL";

            var list = new List<Ellipse>();

            var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
            if (sb.ContainsKey("Password"))
            {
                using (var conn = new OleDbConnection(sb.ConnectionString))
                {
                    conn.Open();
                    using (var reader = new OleDbCommand(query, conn).ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            list.Add(new Ellipse()
                            {
                                Height = size,
                                Width = size,
                                Fill = Brushes.Red,
                                Stroke = Brushes.Red,
                                Tag = new Point(reader.GetDouble(2), reader.GetDouble(3))
                            });
                        }
                    }
                }
            }

            return list;
        }
开发者ID:A-n-d-r-e-y,项目名称:VISLAB,代码行数:31,代码来源:Analyst.cs

示例7: TakeBackup

        private void TakeBackup(Guid id)
        {
#if (!DEBUG)
            var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
            if (sb.ContainsKey("Password"))
            {
                SQLAdmin.MakeRestore(null, id,
                    sb.DataSource,
                    sb["Initial Catalog"].ToString(),
                    @"\\toshiba\English.Cafe.2008.MP3.64kbps\",
                    sb["User ID"].ToString(),
                    sb["Password"].ToString());
            }
#endif
        }
开发者ID:A-n-d-r-e-y,项目名称:VISLAB,代码行数:15,代码来源:ProjectManager.cs

示例8: MakeBackup


//.........这里部分代码省略.........

            //tree = new ExperimentsTree(Path.Combine(projectDir, project.Files.SnapshotTreeFileName));

            //DirectoryPacker.Pack(
            //    modelDir,
            //    Path.Combine(projectDir, project.Files.SnapshotDataFileName),
            //    Tree.root.Id);

            //CreateExperiment(projectDir, Tree.root.Id);

            //project.CurrentExperimentId = Tree.root.Id;
            //project.Save(projectDir);

            //SaveProjectToSettings(project, projectDir);

            //OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, projectName, project.FileExtension));
        //}

        //public void CloneProject(string projectName, string projectDir, string modelFileName)
        //{
            //CreateProject(projectName, projectDir);

            //string modelName = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetInputFileName() : Path.GetFileName(modelFileName);
            //string modelDir = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetWorkingDirectory() : Path.GetDirectoryName(modelFileName);
            //string snapshotDataFileName = string.Format("{0}\\{1}", projectDir, project.Files.SnapshotDataFileName);

            //tree = new ExperimentsTree(string.Format("{0}\\{1}", projectDir, project.Files.SnapshotTreeFileName));
            //DirectoryPacker.Pack(modelDir, snapshotDataFileName, Tree.root.Id);

            //modelDir = string.Format("{0}\\{1}", projectDir, project.Files.ModelDirectory);
            //if (!Directory.Exists(modelDir)) Directory.CreateDirectory(modelDir);
            //DirectoryPacker.UnPack(modelDir, snapshotDataFileName, Tree.root.Id);

            //vissim.Instance.LoadNet(string.Format("{0}\\{1}{2}", modelDir, modelName, modelName.EndsWith(".inp") ? string.Empty : ".inp"));

            //CreateExperiment(projectDir, Tree.root.Id);

            //project.CurrentExperimentId = Tree.root.Id;
            //project.Save(projectDir);

            //SaveProjectToSettings(project, projectDir);

            //OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, project.Name, project.FileExtension));
        //}

        //public void LoadProject(string projectFileName)
        //{
        //    if (string.IsNullOrWhiteSpace(projectFileName)) return;

        //    if (!File.Exists(projectFileName))
        //    {
        //        if (LoadProjectFailed != null) LoadProjectFailed(this, new ProjectEventArgs(projectFileName));
        //        return;
        //    }

        //    projectDir = Path.GetDirectoryName(projectFileName);
        //    Project = Project.Load(projectFileName);
        //    experiment = Experiment.Load(Path.Combine(projectDir, project.Files.ExperimentFileName), project.CurrentExperimentId);

        //    string modelDir = Path.Combine(projectDir, project.Files.ModelDirectory);

        //    //TODO LASTPOINT
        //    if (vissim.Instance.GetWorkingDirectory() != string.Format("{0}\\", modelDir))
        //    {

        //        var filesList = Directory.GetFiles(modelDir, "*.inp");
        //        if (filesList.Length == 0) throw new FileNotFoundException("There are no input file in the model directory");

        //        string modelName = Path.GetFileName(filesList[0]);

        //        vissim.Instance.LoadNet(string.Format("{0}\\{1}{2}", modelDir, modelName,
        //            modelName.EndsWith(".inp") ? string.Empty : ".inp"));

        //        string layoutFileName = string.Format("{0}\\vissim.ini", modelDir);
        //        if (File.Exists(layoutFileName)) vissim.Instance.LoadLayout(layoutFileName);
        //    }

        //    SaveProjectToSettings(projectFileName);

        //    OnProjectLoaded(projectFileName);
        //}

        private bool MakeBackup(Guid id)
        {
#if (!DEBUG)
            var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
            if (sb.ContainsKey("Password"))
            {
                return SQLAdmin.MakeBackup(null, id, ExperimentNumber,
                    sb.DataSource,
                    sb["Initial Catalog"].ToString(),
                    @"\\toshiba\English.Cafe.2008.MP3.64kbps\",
                    sb["User ID"].ToString(),
                    sb["Password"].ToString());
            }
            else return false;
#else
            return false;
#endif
        }
开发者ID:A-n-d-r-e-y,项目名称:VISLAB,代码行数:101,代码来源:ProjectManager.cs


注:本文中的System.Data.OleDb.OleDbConnectionStringBuilder.ContainsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。