コード例 #1
0
ファイル: DBObjectMulti.cs プロジェクト: injeetender/SQLSure
        private void tsbViewObject_Click(object sender, EventArgs e)
        {
            ObjectViewer ov                = new ObjectViewer();
            string       ObjectText        = string.Empty;
            string       ObjectDescription = string.Empty;

            try
            {
                using (DataStuff sn = new DataStuff())
                {
                    DataTable dt = sn.GetDatabaseObjectText(ConnectionString, DatabaseName, ObjectName);

                    if (dt.Rows.Count > 1)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ObjectText        = row["FullDefinition"].ToString();
                            ObjectDescription = row["ROUTINE_NAME"].ToString() + ": " + row["ROUTINE_TYPE"].ToString();
                        }
                    }
                    else
                    {
                        ObjectText        = LoadHelpText(ConnectionString, DatabaseName, ObjectName);
                        ObjectDescription = ObjectName;

                        if (ObjectText.Trim() == "")
                        {
                            dt = sn.GetTableHelpText(ConnectionString, DatabaseName, ObjectName);

                            foreach (DataRow row in dt.Rows)
                            {
                                ObjectText = row[0].ToString();
                            }

                            ObjectText = ObjectText.Replace("~", Environment.NewLine);
                        }
                    }
                }

                ov.ObjectDescription = ObjectDescription;
                ov.ObjectText        = ObjectText;
                ov.ConnectionString  = ConnectionString;
                ov.DatabaseName      = DatabaseName;
                ov.ObjectName        = ObjectName;
                ov.AliasName         = ServerAlias;

                ov.Show();
            }

            catch
            {
            }
        }
コード例 #2
0
        private string GetObjectText(string CnnString, string DBName, string ObjName)
        {
            string ObjectText        = string.Empty;
            string ObjectDescription = string.Empty;

            try
            {
                using (DataStuff sn = new DataStuff())
                {
                    DataTable dt = sn.GetDatabaseObjectText(CnnString, DBName, ObjName);

                    if (dt.Rows.Count > 1)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ObjectText        = row["FullDefinition"].ToString();
                            ObjectDescription = row["ROUTINE_NAME"].ToString() + ": " + row["ROUTINE_TYPE"].ToString();
                        }
                    }
                    else
                    {
                        ObjectText = LoadHelpText(CnnString, DBName, ObjName);

                        if (ObjectText.Trim() == "")
                        {
                            dt = sn.GetTableHelpText(CnnString, DBName, ObjName);

                            foreach (DataRow row in dt.Rows)
                            {
                                ObjectText = row[0].ToString();
                            }

                            ObjectText = ObjectText.Replace("~", Environment.NewLine);
                        }
                    }

                    return(ObjectText);
                }
            }

            catch
            {
                return("");
            }
        }