Wrox Programmer Forums
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 26th, 2007, 07:58 PM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Data from Recordset

Hi, this is probably the worse question anyone has asked, but here goes.
I have a connection to my sql db, using vb05, I can dump the recordset into a datagridview object with little effort, but, when querying for single record and single field, I cant seem to dump the returned value to a variable,

eg:
       sqlConnect.Open()

        ' Dim y As Integer
        Dim sql As String
        Dim series As String

        sql = "select Series from ModelMstr where partno='" + Part + "'"

        Dim cmd As SqlCommand
        cmd = New SqlCommand(sql, sqlConnect)

        Dim adapter As SqlDataAdapter
        adapter = New SqlDataAdapter(cmd)
        Dim row As Integer

        Dim ds As DataSet
        ds = New DataSet()
        adapter.Fill(ds)
        'Dim x As String
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataSource = ds.Tables(0)
        Me.ComboBox1.DataSource = ds
        Me.ComboBox1.DataSource = ds.Tables(0)
        Me.ComboBox1.DisplayMember = "PartNumber"
        Series=Combobox1.text


 
Old January 17th, 2008, 01:08 AM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you need to also assign the .ValueMember property to "PartNumber" as well when setting the datasource. I may be wrong but try it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to bind data from a recordset to a combobox? wayne62682 Access VBA 6 April 2nd, 2006 08:45 PM
Structuring Recordset data brendonsmith XSLT 2 January 19th, 2004 07:14 PM
How Do I Reuse data from a RecordSet? steve456 Classic ASP Professional 2 October 21st, 2003 05:30 AM
Can't pull data from ntext field into recordset. rstelma Classic ASP Databases 1 August 26th, 2003 03:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.