예제 #1
0
        private static string GetConstraint(IColumn columnName)
        {
            const string command = "select object_name(cdefault) from syscolumns where [id] = object_id(@tn) and [name] like @cn ";

            using (var cmd = new SqlProxyCommand(command, GlobalInfo.DBaseInfo.dbManager.DB_Connection))
            {
                var tn = new SqlProxyParameter("@tn", DbType.String, 64);
                var cn = new SqlProxyParameter("@cn", DbType.String, 64);
                cmd.Parameters.Add(tn);
                cmd.Parameters.Add(cn);

                tn.Value = "dbo." + columnName.Table;
                cn.Value = columnName.Name;

                var constraint = string.Empty;
                try
                {
                    var result = cmd.ExecuteScalar();
                    if (result != null)
                    {
                        constraint = result.ToString();
                    }
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                }

                return(constraint);
            }
        }
예제 #2
0
 public T ExecuteScalar <T>()
 {
     scc.CommandText = Query;
     return((T)scc.ExecuteScalar());
 }