コード例 #1
0
ファイル: H.cs プロジェクト: angelbitel/SiroInventario
        internal static SqlDataSource BindToData(string queryComand)
        {
            //BUSCAR LA CADENA DE CONEXXION DEL CONTENEDOR DE DATOS SELLECCIONADO StoredProcQuery
            var cnnContext = new SiroDb();
            var cnn        = cnnContext.Database.Connection.ConnectionString.Split(';');
            //// Create a data source with the required connection parameters.
            MsSqlConnectionParameters connectionParameters = new MsSqlConnectionParameters(cnn[0].Split('=')[1], cnn[1].Split('=')[1], cnn[3].Split('=')[1], cnn[4].Split('=')[1], MsSqlAuthorizationType.SqlServer);
            SqlDataSource             ds    = new SqlDataSource(connectionParameters);
            CustomSqlQuery            query = new CustomSqlQuery();

            query.Name = @"customQuery";
            query.Sql  = queryComand;
            // Add the query to the collection.
            ds.Queries.Add(query);
            // Make the data source structure displayed
            // in the Field List of an End-User Report Designer.
            ds.RebuildResultSchema();

            return(ds);
        }
コード例 #2
0
        public async Task <bool> Verificar()
        {
            bool conecto = false;
            await Task.Run(() =>
            {
                try
                {
                    using (var cnn = new SiroDb())
                    {
                        cnn.Database.Connection.Open();
                        conecto = (cnn.Database.Connection.State == System.Data.ConnectionState.Open);
                    }
                }
                catch (Exception ex)
                {
                    Message = ex.Message;
                    conecto = false;
                }
            });

            return(conecto);
        }