如何连接数据库 [英] how can I connect to database

查看:107
本文介绍了如何连接数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个,但我不能连接DataBase

I use this but I can't connect DataBase

  conn1.Open();
    using (OracleCommand crtCommand = new OracleCommand);


推荐答案



To make it dynamic use this;

    string sentence = "";
    string formatprototype = "";//This will hold the string to be formatted.
    string output="";

    public void SearchString()
    {
        string pattern = @".*[ ]+?[\""]{1}(?<String>[a-zA-Z0-9_]*)[\""]{1}[ ]+?MINVALUE[ ]*(?<MinValue>[-?\d]*)[ ]*MAXVALUE[ ]*(?<MaxValue>[\d]*)[ ]+?[INCREMENT]*[ ]+?[BY]*[ ]+?(?<IncrementBy>[\d]*)[ ]+?[START]*[ ]+?[WITH]*[ ]+?(?<StartWith>[\d]*)[ ]+?[CACHE]*[ ]+?(?<Cache>[\d]*)\s+?";
        Regex regex = new Regex(pattern);
        Match match = regex.Match(sentence);
        Group @string = match.Groups[1];
        Group minvalue = match.Groups[2];
        Group maxvalue = match.Groups[3];
        Group incrementby = match.Groups[4];
        Group startswith = match.Groups[5];
        Group cache = match.Groups[6];
        formatprototype = @"CREATE SEQUENCE ""{0}"" MINVALUE {1} MAXVALUE {2} INCREMENT BY {3} START WITH {4} CACHE {5} NOORDER NOCYCLE";
        if (minvalue.Value.StartsWith("-"))
        {
            output = string.Format(formatprototype, @string, minvalue, maxvalue, incrementby, maxvalue, cache);
        }
        else if (!minvalue.Value.StartsWith("-"))
        {
            output = string.Format(formatprototype, @string, minvalue, maxvalue, incrementby, minvalue, cache);
        }
        MessageBox.Show(output);
    }

假设 SearchString()是你正在做这个东西的函数。并确保将从数据库中提取的每个字符串分配给 sentence 。尝试并回复如果它工作或不是。

Assume that SearchString() is the function in which you are doing this stuff.And make sure to assign each string that is extracted from database,to sentence.Try it and reply if it worked or not.

这篇关于如何连接数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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