?
Solved

Displaying and Passing values from a dataadapter

Posted on 2006-11-27
3
Medium Priority
?
214 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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

752 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