Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Displaying and Passing values from a dataadapter

Posted on 2006-11-27
3
Medium Priority
?
215 Views
Last Modified: 2010-04-23
I'm hoping this is an easy one but I'm just overlooking something simple.


I have a data adapter a that pulls to values from the database.    One is a complete name of a document the other is a reference number.  I'm displaying the document name in a drop down for the users to select - it works fine, but when they select it, I want to pass the associated reference number  instead of the documents name.

code:

'sqlGetIMGDocsAdapter
        '
        Me.sqlGetIMGDocsAdapter.SelectCommand = Me.SqlSelectCommand41
        Me.sqlGetIMGDocsAdapter.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "sp_GetIMGDocs", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("IMGDOC_Code", "IMGDOC_Code"), New System.Data.Common.DataColumnMapping("DOC_Name", "DOC_Name")})})
        '
        'SqlSelectCommand41
        '
        Me.SqlSelectCommand41.CommandText = "[sp_GetIMGDocs]"
        Me.SqlSelectCommand41.CommandType = System.Data.CommandType.StoredProcedure
        Me.SqlSelectCommand41.Connection = Me.SqlConnection3
        Me.SqlSelectCommand41.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        '

Then I just do a fill

  Ds_IMGDoc221.Clear()
        sqlGetIMGDocsAdapter.Fill(Ds_IMGDoc221)




Suggestions?

Thanks in advance
0
Comment
Question by:TimSweet220
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 400 total points
ID: 18020488
the best suggestion i have is to databind the dataset from the dataadapter then do:
datagridview1.columns("Reference_Number").visible=false
when they select it datagridview1.item("Reference_Number",currentrowindex).value will equal what you need

Good Luck
0
 
LVL 5

Assisted Solution

by:proten
proten earned 1600 total points
ID: 18021902
Why not set the text to the datafield you wish to display, and the value to the datafield value you wish to return

i.e.

dropdownlist1.DataSource = ds.tables(0)
dropdownlist1.DataTextField = "DataDisplay"
dropdownlist1.DataValueField = "DataValue"

This will send back the value that is transparent to the user when selected but display the display field to the user.
0
 
LVL 5

Accepted Solution

by:
proten earned 1600 total points
ID: 18021919
ds is the DataSet with the data from your dataadapter

DataDisplay and DataValue are the names of the database fields returned,.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question