Showing posts with label bind. Show all posts
Showing posts with label bind. Show all posts

Friday, March 23, 2012

how can I bind to only partial columns of a table?

I have the same question. Did you figure our how to do so?
Thank you very much
Yev
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.comalways bind to a view of a table, not directly to a table, so you can contro
l
the columns you want to bind.
MCH
"Yevheniy" wrote:

> I have the same question. Did you figure our how to do so?
> Thank you very much
> Yev
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
>

How can I bind to an SqlDataSource from Code

My code behind file builds a select statement and I would like to fill an SqlDataSource control with it. Can some show me an example of how I might do that? Maybe something like this?

Me.SqlDataSourceSearchResult.ConnectionString ="ConnectStr"Me.SqlDataSourceSearchResult.SelectCommand ="SelectStatement"

gvSearchResult.DataSource =

Me.SqlDataSourceSearchResult

gvSearchResult.DataBind()

Hello Jackxxx,

If you are going to be doing this in code-behind, I would not bother with the SqlDataSource control. I would bind the data directly to the destination control as follows: -

Dim conn As New SqlConnection("YourConnectionString")
Dim command As New SqlCommand("SELECT * FROM YourTable", conn)
Dim da As New SqlDataAdapter(command)
Dim tblData As New DataTable
da.Fill(tblData)
conn.close()

gvSearchResult.DataSource = tblData
gvSearchResult.DataBind()

Also add the following 2 lines at the top of the code behind if they are not there already: -

Imports System.Data.SqlClient
Imports System.Data

Kind regards

Scotty

|||

Scotty,

I was trying to use the sqldatasource so that I could some how use its built in sort functionality.

|||

Hello Jackxxx,

I see now. In that case, do the following after populating tblData: -

Dim dvData as new DataView(tblData)

dvData.Sort = "MyField DESC" ' you can also apply filtering on a DataView

mygrid.DataSource = dvData ' binds to the DataView, not the DataTable

mygrid.DataBind()

Kind regards

Scotty

|||

I'm really hoping to find a way to bind to the SqlDataSource so that I can take advantage of sorting and paging for multiple fields without all the extra coding.

There must be a way.

|||

Hi Jack,

Suppose your SqlDataSource returns a DataSet, you can

mygrid.DataSource = sqlDatasource.Select()
mygrid.DataBind()

However, if you need to take advantage of sorting and paging, I suggest you bind with the designer.

How can I bind assemblies of DEFINITE version of SSIS dataflow component to a package.

I have several versions of one SSIS Dataflow component. I need to bind some of them( definite version) to my SSIS package. How can I do that?

Thanks in advance.

What do you mean by binding your assemblies to a package?

Thanks,

Bob

|||

Hi,

I mean that I developed a SSIS package using Dataflow components which I had developed before. The assembly of these components has version number 1.0.0.0, for instance.

After that I improved components( version 2.0.0.0, for instance) and I want to use them within the same package with components version 1.0.0.0. .

I can't put assemblies with the same name into folder \dts\pipelinescomponents\ .

Because If I replace components v. 1.x by v.2 that I will have to tune all other dataflow components again( lookups, unions and etc).

And I have to create the same component having diferent name. For example componentnameV1.dll, componentnameV2 and etc.

Does solution exist for this situation?

Thanks in advance.

|||

I think the easiest way would be to replace the component in the PipelineComponents folder and the GAC and then change the version in the package XML. You'll have to test it though as I have not tried it.

Thanks,

Bob

|||

Thank you very much for your idea. "change the version in the package XML. You'll have to test it though as I have not tried it."

I changed version in the package XML. And the package works with new version of components successfully.

How can I bind assemblies of DEFINITE version of SSIS dataflow component to a package.

I have several versions of one SSIS Dataflow component. I need to bind some of them( definite version) to my SSIS package. How can I do that?

Thanks in advance.

What do you mean by binding your assemblies to a package?

Thanks,

Bob

|||

Hi,

I mean that I developed a SSIS package using Dataflow components which I had developed before. The assembly of these components has version number 1.0.0.0, for instance.

After that I improved components( version 2.0.0.0, for instance) and I want to use them within the same package with components version 1.0.0.0. .

I can't put assemblies with the same name into folder \dts\pipelinescomponents\ .

Because If I replace components v. 1.x by v.2 that I will have to tune all other dataflow components again( lookups, unions and etc).

And I have to create the same component having diferent name. For example componentnameV1.dll, componentnameV2 and etc.

Does solution exist for this situation?

Thanks in advance.

|||

I think the easiest way would be to replace the component in the PipelineComponents folder and the GAC and then change the version in the package XML. You'll have to test it though as I have not tried it.

Thanks,

Bob

|||

Thank you very much for your idea. "change the version in the package XML. You'll have to test it though as I have not tried it."

I changed version in the package XML. And the package works with new version of components successfully.

How can I bind assemblies of DEFINITE version of SSIS dataflow component to a package.

I have several versions of one SSIS Dataflow component. I need to bind some of them( definite version) to my SSIS package. How can I do that?

Thanks in advance.

What do you mean by binding your assemblies to a package?

Thanks,

Bob

|||

Hi,

I mean that I developed a SSIS package using Dataflow components which I had developed before. The assembly of these components has version number 1.0.0.0, for instance.

After that I improved components( version 2.0.0.0, for instance) and I want to use them within the same package with components version 1.0.0.0. .

I can't put assemblies with the same name into folder \dts\pipelinescomponents\ .

Because If I replace components v. 1.x by v.2 that I will have to tune all other dataflow components again( lookups, unions and etc).

And I have to create the same component having diferent name. For example componentnameV1.dll, componentnameV2 and etc.

Does solution exist for this situation?

Thanks in advance.

|||

I think the easiest way would be to replace the component in the PipelineComponents folder and the GAC and then change the version in the package XML. You'll have to test it though as I have not tried it.

Thanks,

Bob

|||

Thank you very much for your idea. "change the version in the package XML. You'll have to test it though as I have not tried it."

I changed version in the package XML. And the package works with new version of components successfully.

sql

How can I bind a ReportViewer to a DataSourceControl?

I have created a System.Web.UI.DataSourceControl which interfaces with an external application and, with the help of a DataSourceView, generates an IEnumerable collection which can be used as a binding source. The primary use is to publish a table of data to a web page using a GridView which is bound to the DataSourceControl via it's DataSourceID property. All of this is working perfectly and now I want to be able to publish this same grid to a ReportViewer running in Local Mode. What is the proper way to do this? I know I need to design a report, but am unclear about how to make the connection between my DataSourceControl and the report. Here's what I have done so far, but am not sure if I am on the right path.

Starting with my existing, working page which has one DataSourceControl and one Gridview bound to the control.

1. Add a ReportViewer to the page.
2. Select "Design a new report" from the viewers smart-tag
3. Add a Table to the report
4. Add a DataSet to the project
5. Add a DataTable to the DataSet
6. Add 2 columns to the DataTable (assuming the case where my DataSourceControl will be returning 2 columns)
7. Now that I've added the DataSet and DataTable, it appears in the ReportViewer's "Website Data Sources" toolbox, so I drag "Column1" and Column2" out onto the table. This gives me 2 headers and the data cells look like "=Fields!Column1.Value" etc.
8. Only after I have added the columns can I go back to the ReportViewer's smart tag and select "Choose Data Sources". This brings up a dialog with a 2 column table with the headings "Report Data Source" and "Data Source Instance". The ReportDataSource is already set to "DataSet1_DataTable1" and the "DataSourceInstance is defaulted to "(None)" but has a drop-down with which I can either select the instance of my DataSourceControl which is on the page (DataSourceControl1) or else select "<New Data Source...> which brings up a Data Source Configuration Wizard. I choose to select my Data Source Control instance.
9. I select "Rebind Data Sources" on the Report Viewer's smart-tag. This adds a new "Object Data Source" to the page, but I don't see how this has any relation to my DataSourceControl. It's SelectMethod is set to "GetData" and its TypeName is set to "DataSet1TableAdapters." which doesn't make much sense to me.

What am I missing? Is there a simpler way to do this? Can I bind a ReportViewer to my DataSource control directly? or do I need to add methods to my DataSourceControl which return the tabular data as a DataTable inside of a DataSet?

Thanks for any help. This is way too confusing.no replys? is my question too complex? i would think this would not be too hard. any help would be greatly appreciated.