How tableAdapter retrieve the value into Byte[]

Hello,

 I have no idea on how to do the tableAdapter to get the varbinary to byte[].  Please advice.

 the varbinary has stored the pdf documents.

?? = Table1Adapter.GetImageByGuid(RecID)

 Thanks.

 Wu


Thanks!

Wu
0
wuchunwai
1/16/2009 11:58:54 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

4 Replies
582 Views

Similar Articles

[PageSpeed] 5

 Hi,

You need to add a new query to your table adapter , so this is the steps:

  1.  right click on the Table adater and select "Add -> Query", then click next.
  2. Select "Use Sql statments" or store procedure if you have one., then click next.
  3. Choose "Select which returns single value" , then click next.
  4. type your select query , example "SELECT Image_data FROM TableName where ImageId=@ImageId" .
  5. Then provide a name for your new query .
  6. After that click finish .
  7. Now you should see the New function listed in the Adapter methods , right click on that method and select Properties.
  8. Through the Properties window , change the "ExecuteMode" to Scalar.

Now the newly added method must be avalailabe in the adapter instance and must returns "object" variable, then you can cast the return object instance to byte[].

 

More on working with TableAdateprs queries , follow the link below:

http://msdn.microsoft.com/en-us/library/6s413yfa(VS.80).aspx

 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
1/17/2009 9:02:11 AM

Hi Anas,

 Thanks for your reply. I changed the ExecuteMode to Scalar and the code of BLL, but it has problem that the BLL can not be compiled.  Please advice.

[System.ComponentModel.DataObjectMethodAttribute
      (System.ComponentModel.DataObjectMethodType.Select, true)]
    public byte[] RequestITDAL.Table1DataTable SelectPDF(Guid RecID)
    {

 Table1TableAdapter table1ObjectAdapter =
                new Table1TableAdapter();
        byte[] returnValue = (byte[])table1ObjectAdapter.Table1_SelectImage(RecID);

        return returnValue;

      
    }

  Error:

Error 1 'RequestITDALTableAdapters.Table1TableAdapter' does not contain a definition for 'GetImageByGUID' 

  Error 2 ; expected  <<public byte[] RequestITDAL.Table1DataTable SelectPDF(Guid RecID)>>

I am new to programming.  

 Thanks.

 Wu


Thanks!

Wu
0
wuchunwai
1/17/2009 11:08:06 AM

Hi,

Even I change to the BLL code at the following: 

[System.ComponentModel.DataObjectMethodAttribute
      (System.ComponentModel.DataObjectMethodType.Select, false )]
    public RequestITDAL.Table1DataTable SelectPDF(Guid RecID)
    {
        return Adapter.Table1_SelectImage(RecID);
      
    }

Errors:

Error 1 'RequestITDALTableAdapters.Table1TableAdapter' does not contain a definition for 'GetImageByGUID'

Error 2 Cannot implicitly convert type 'object' to 'RequestITDAL.Table1DataTable'. An explicit conversion exists (are you missing a cast?) 

Thanks

Wu


Thanks!

Wu
0
wuchunwai
1/17/2009 2:05:45 PM

Hi Anas,

 I figure like this.  Can you tell me the way I do is correct or not?

[System.ComponentModel.DataObjectMethod
      (System.ComponentModel.DataObjectMethodType.Select)]
    public static byte[] Table1_GetPDF(Guid RecID)
    {
        Table1TableAdapter table1ObjectAdapter =
                new Table1TableAdapter();
        byte[] returnValue = (byte[])table1ObjectAdapter.Table1_SelectImage(RecID);

        return returnValue;

    }

Thanks for your reply and hope to learn more.

Wu


Thanks!

Wu
0
wuchunwai
1/17/2009 3:09:03 PM
Reply:

Similar Artilces:

Retrieve an object value using dynamic object names
Is it possble to build an object name in a string and then retrieve the value of that object?Basically my old ASP page had a large table of data whereby each row was an individual form. At the end of each row was a button to submit just that rows form and the elements within it.So to rebuild the table in .net i thought I would be able to just use the single form but each row of objects have a rownumer appended to the end of the object IDs. Therefore I can read the id of the button pushed and know which row the user was on. Whilst i can retrieve the rownumber from the end of the button ID, I ...

new to .net, need help setting db values from checkbox's then retrieving value to a label control
Hi, Being new to asp.net i know this possible i just can't quite get it right!  I need a page with 5 checkbox's that when submitted sets the bit values in DB fields to checked. Then i need another page that retrieves the records of the checkboxes, but instead of having the db pre-set checkboxes on the second page i want it to turn on label web controls depending on if the check box is set.. I hope that makes sense?!! Can anyone point me in the right direction or to a suitable tutorial? Thanks in advance Ben Excellent article here.http://www.heliosfx.com...

Retrieve values from a collection object
Hi, I have a collection with an object containing a few properties.  I want to retrieve some data from that collection.  The object is a selfmade class as below.1 &lt;Serializable()&gt; Public Class CPU 2 3 Private mPosition As String 4 Public Property Position() As String 5 Get 6 Return mPosition 7 End Get 8 Set(ByVal value As String) 9 mPosition = value 10 End Set 11 End Property 12 13 Private mCard As String 14 Public Property Card() As String ...

Retrieving values from a User Object
It's been a while since I have been working with PB. Can someone please refresh my memory on what I can use in order to retrieve a value the user entered in a User Object. thanks in advance. I would create a function on the user object that returns the value I'm looking for. That way I put the onus of figuring out how to get that value on the user object, not the requestor - who should not know (or care) about what's inside the uo anyway. HTH, steve [TeamSybase] ...

Retrieve Value from Session Object
Hi All,In the code below i am assigning datarow value to a session object of type string variable. I am unable to grab each value from the session variable. Assigning to Sessionpublic object RowData(object oo)        {            System.Data.DataRowView o = (System.Data.DataRowView)oo;            DataRow R = o.Row;            HttpContext.Current.Session["DataRowValue"] = R.ToStrin...

RowEditing
I am attempting to bind a radio button list in the EditItem template of a GridViewRow.  I have read several posts but I am not sure which event to put the code in.  Since I am only displaying the list when editing, I thought about adding it to the RowEditing event.  Would it be better in the RowDataBound or RowCommand event?Is there a way to access the original data in a grid row?  Most examples I have seen reference row.Cell[0], but I would rather access the data row because the field I need does not need to be a column in the GridView (I know I can make it a hidden colu...

retrieve original datasource object
Is it possible to retrieve the collection object that was originally used to bind the datagrid? I know that you can loop through each cell in each item and pull the values that way, but if the datagrid only displays a selct number of fields from the collection, is it possible to gain access to the other values that are not being displayed? mbehrend, The ItemDataBound event of the grid will give you access to the DataItem that you will need to cast to your custom object using the event args: private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e){ ...

Retrieve Value From DataSource Contorl?
Is it possible to retrieve the value of a DataSource control manually in code? For example, from a DataReader I can call a number of methods (GetString(), etc.). Is there anything similar in the DataSource controls? Thanks, Charlie Hey, You can invoke the Select() method, which returns an IEnumerable or IEnumerator object.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4)....

Passing Multiple values to an object datasource
Hello, Am using the following code below to pass values to an object datasource, But how do i pass multiple values   protected void ObjectDataSource_PhoneGroups_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["username"] = Session["username"].ToString(); }   I just dont want to pass a session value, i also want to pass a string value of "phonebook" how do i do this ? Or do i add     protected void ObjectDataSource_PhoneGroups_Selecting(object sender, ObjectDataSourceSelecti...

Can a DataSource set the default value in a DropDownList (or the list fetch the value from a DataSource)?
Hi I have a DropDownList that gets its values from a DataSource-control. Nothing magic so far. What makes me scratch my head is that I need to set the default (selected) value in the drop down. As the values come from a data source, I do not know the key/value/index of the default I. Is there a possibility to make the drop down "ask the data source" which key should be the default (that is, only if the drop down is populated the first time, of course)? Background: I have an application where an administrator can set the "standard" month that the application s...

retrieving values from list box then use this values to retrieve data from db to gridview
 help.. can anyone give me some idea or examples regarding this one... the select formula should be something like this.. but not totally like this..Dim selectinfo = (from a in db.PRs _where a.PRID = item[1] and a.PRID = item[2] and a.PRID = item[3] _select a) those item[1], item[2]....etc are the values inside the listbox...  how will i apply that into the select command... using loop...thank you in advance... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) string selectedItems = "";for (int vLoop = 0; vLoop < lstIte...

Replace the .NET 1.1 Behavior-Object with the .NET 2.0 Tag-Object , How to?
Hello, to set the Style - Attribute of my custom controls tag in source view from within its designer i use now the following code:Behavior.SetStyleAttribute("Left", false, val, true);This works fine but my visual studio 2005 / asp.net 2.0 says that the Behavior object is obsolete. The recommended alternative is the Tag object. But when i use it to set the Style attribute it doesn't work . I can set all other attributes or even create new ones using this Tag object but it does'nt work for the style attribute at all. What am i doing wrong? If I can't set the style attribute in my custom contr...

Retrieving single value through tableadapter and returning to Datalist
I have this sql in a tableadapter. SELECT     COUNT(*) AS Expr1FROM         tblArticle WHERE ArticleCatID = @ArticleCatID It counts the numbers of articles in a particular category. My aspx page call it with: <asp:Label ID="Label1" runat="server" Text='<% # GetArticlesbyID(Eval("ACategoryID")).ToString %>'></asp:Label>Protected Function GetArticlesbyID(ByVal CatID As Integer) Dim tblArticles As New tblArticleTableAdapter Dim totArticles As articles.tblArticleDataTable t...

Retrieving of deleted object from AD using .NET
Anyone has any idea how to retrieve deleted object from AD using VB.NET or C#? http://msdn.microsoft.com/library/en-us/netdir/ad/retrieving_deleted_objects.asp this is link explains the steps but its in C++. those function in the example can be found in .NET by referencing to ActiveDs type library. but i have got some problem using it. Pls help.. anyone please.. i really need help on this...

Retrieving unique values from DataTable in VB .NET
I have a DataAdapter filling a DataTable with a result set from a stored procedure.  In my stored procedure I'm returning DISTINCT records from the query.  A valid return would include "duplicate" records...which aren't truly duplicate but the data value would appear to be duplicate.  The DataTable is returned to a web page where it loads a dropdownlist box.  I don't want the "duplicate" data to display in the dropdownlist...how would I programmatically eliminate duplicates?beejay...

Retrieving the values of Excel check boxes in .NET
I have an Excel spreadsheet which contains multiple un-grouped check boxes (from the Forms toolbar) which are not linked to any particular cell(s). I want to read their values in .NET code. For this I'm using 'Microsoft Office Interop Excel' and 'Microsoft Vbe Interop Forms' libraries. This is the code I'm using: String excelFile = "C:\\FileName.xls"; Excel.Application estimate = new Excel.Application(); Excel.Worksheet workSheet = new Excel.Worksheet(); estimate.Workbooks.Open(excelFile, 0, true, 5, "", &qu...

Object Datasource and Custom Object
Hey, I have an object datasource that populates a detailsview.  I know how to update the changes using a BLL method like so: public static UpdateUser(string Username, string Surname); However I would like to use the objects update() method ive created that essentially calls: public static UpdateUser(User user); The question is, how do I access the fields that are contained within the details view?  im guessing .FindControl() but i dont have the ID.  the other way I suppose is to itterate through all the controls within in it?  there must be a better way though? The second question is, where do I call the entities update method and set there properties?  on the object datasource's inserting event?  Detailsview OnItemInserting event?  Or somewhere else? Thanks in advanceDavid Kiffhttp://DavidKiff.co.uk-- "Mark As Answer" If my reply helped you -- In ObjectDataSource, there are some attribute. One is TypeName that I believe you know is your class name. One is UpdateMethod that should be "UpdateUser" in your case. Then, one is DataObjectTypeName, most important for your case, that takes your object name. In your case, it should be User. After you put all of them in the ObjectDataSource, you should be able to do the update. Hope it helps"Object reference not set to an instance of an object" sounds very promising!  Im guessing the textboxes will automatically mapover to the appropriate prop...

Gridview Search Without Object Datasource Filter ParametersGridview Search Without Object Datasource Filter Parameters
Couple weeks ago I read a article about highlighted search in Gridview  (http://blog.evonet.com.au/post/2008/06/25/Gridview-with-highlighted-search-results.aspx) and in my project I used things I learned but now things changed I have a gridview and in code I give its datasource so because I dont use any objectdatasource I dont know where to write my filtering parameters. Is there anyway to use filtering without objectdatasource, or is there a way to give objectdatasource an source then bind it to my gridview. My code:  //No objectdatasource how can I conduct a search?GridView1.Da...

Retrieving Value From dw's computed object
Hello, I'm using Powerbuilder 6.5.1, and I was wondering if anybody knows a way to retrieve the Value, not expression, of a computed object for display in a text field on the window itself? All I've been able to do is grab the expression, and that doesn't help me very much. I know there's other ways I could go about this, but if there's a way to just grab it from the computed object, it would make the most sense. ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp Brian You should be able to use the GetI...

does dw.net 2.x support object datasource
does dw.net 2.x support object datasource thanks vsv No. That is something we are looking at for version 3.0. Regards, Dave Fish Sybase On 3 Aug 2007 12:33:46 -0700, "vsv" <nospam@nospam.com> wrote: >does dw.net 2.x support object datasource > >thanks >vsv > with mapping to Linq & entity framework? or DatwindowObject Source by itself. thanks vsv "Dave Fish [TeamSybase]" <dfish@[N0Spam]sybase.com> wrote in message news:8u57b39g068kbrs7d8rd82f24sem4cn8dp@4ax.com... > No. That is something we are looking at ...

Object datasource with default value for next row in a gridview
An object datasource of a generic list of blank order data objects including date, name, and amount is bound to the datasource of a gridview for data entry. How can the object list (or javascript?) be mainpulated such a way as user fills in a date on the 1st row, that date will be placed and shown in the next row as default for user's convenience before the cursor moves into that row? (The gridview plainly displays the blank object list for data entry without any select/ update/dlete commands). My first thought is, whenever an object's date is entered, fill the blank date of the next...

Gridview, Passing more than one value in Object DataSource and Gridview
Can anyone let me know how to modify the tutorial at http://www.asp.net/learn/data-access/tutorial-07-vb.aspx so that it get the SupplierID as well when viewing the result for a product.Thanks for any help  I found the answer myself. Thanks anyway ...

help with stored procedure returning a value (and then retrieving it in .NET)
Hi guys,  The methods for connecting to the db, various functions that use (executescalar() etc), were not written by me.  This will be my first time dabbling with these functions... So I am in the process of writing a stored procedure.  All it does is scan tbl_inv_finalized to see if a user has finalized (there could be multiple records, i.e. employeeX | 7/8/2008 10:12:47 AM | 2009 (school year) | 330 (building number) employeeX | 5/30/2008 10:00:00 AM | 2008 | 330 The goal here is that... there is another table that will define the 'finalize periods' throughout t...

Typed Datasets, Retrieving identity value when inserting with TableAdapter.Update()
I have a typed dataset that is based on stored procedures. There is a stored procedure for Insert, Update, Select, and Delete configured for the adapter. My insert stored procedure terminates the INSERT statement with semicolon and then does a SELECT SCOPE_IDENTITY() to return the inserted identity value. I can't seem to get this value though. My typed dataset is called EventEntry. My code creates a new instance of EventEntryDataTable and a new instance of EventEntryRow. I set all properties of the EventEntryRow, add it tot he table adapter with the generated "AddEventEntryRow()" method, and...

Web resources about - How tableAdapter retrieve the value into Byte[] - asp.net.object-datasource

Handling ReportViewer Parameters
Consider that in a Reporting Services report processor-generated report, all of the parameters (both query and report) are handled behind the ...

The Parable of The Road Line Painter
-*+Way back in the day when lines were first being painted on roads. The early lines were painted by hand. In those days, a painter was hired ...

Selecting a CMS: developing usage scenarios
EBSCOhost serves thousands of libraries with premium essays, articles and other content including Selecting a CMS: developing usage scenarios. ...

Sample code for a very very simple VB database application
I wrote a short piece for Personal Computer World about making a simple Windows Forms database application. I did this because I get a lot of ...

DotNetNuke Modules – Data Access Layer
-*+On Tuesday, we started working on the code for our Data Access Layer by having CodeSmith generate some classes for us. Today, we are going ...

Resources last updated: 2/18/2016 10:25:22 AM