This is a migrated thread and some comments may be shown as answers.

The name 'DataSourceHelperCS' does not exist in the current context

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
berto
Top achievements
Rank 1
berto asked on 24 Nov 2012, 11:40 PM
Hello,
I wanted to test second solution from: http://www.telerik.com/help/aspnet-ajax/grid-performing-batch-updates.html

Client side editing.

In code:

public DataTable ProductsTable
{
 
    get
    {
        DataTable res = (DataTable)this.Session["ProductsTable"];
        if (res == null)
        {
            res = DataSourceHelperCS.GetDataTable("SELECT [ProductID], [ProductName], [Discontinued] FROM [Products]");
            this.Session["ProductsTable"] = res;
        }
 
        return res;
    }
}

I have issue with DataSourceHelperCS. How I can avoid mentioned error?

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 28 Nov 2012, 01:47 PM
Hi Andrzej,

The DataSourceHelperCS class is just a data access layer in which the function GetDataTable will return a table. You can remove it and try out something like this:
DataTable myDataTable = new DataTable();   
     
public static DataTable GetDataTable(string query)   
{   
    DataTable information = new DataTable();   
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMA_project"].ConnectionString);   
     
    try   
    {   
        conn.Open();   
        SqlDataAdapter adapter = new SqlDataAdapter();   
        try   
        {   
            adapter.SelectCommand = new SqlCommand(query, conn);   
            adapter.Fill(DataTable);   
        }   
        finally   
        {   
            if (!Object.Equals(adapter.SelectCommand, null)) 
                adapter.SelectCommand.Dispose();   
        }   
    }   
    finally   
    {   
        if (conn.State == ConnectionState.Open)   
        {   
            conn.Close();   
        }   
    }   
    return myDataTable;   
}
It should perform the same way.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
berto
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or