Solved

Displaying and Passing values from a dataadapter

Posted on 2006-11-27
3
208 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
  • 2
3 Comments
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 100 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 400 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 400 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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