473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

VB.NET Late-binding problem

chathura86
227 100+
Hi
i have bounded a dataset to a listbox and i want to get the selected values when i clicked add and write them to a text box. here is the code i'v used

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class frmContactList
  4.     Private conContacts As SqlConnection
  5.     Private cmdContacts As SqlCommand
  6.     Private dtaContacts As SqlDataAdapter
  7.     Private dtsContacts As DataSet
  8.  
  9.     Private Sub frmContactList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
  10.         txtNumberList.Text = frmSendSMS.txtTo.Text
  11.  
  12.         conContacts = New SqlConnection("Data Source=localhost;Initial Catalog=ABC;Integrated Security=True")
  13.         cmdContacts = New SqlCommand("SELECT ('<' + PHONE_MOBILE + '> ' + TITLE + '. ' + F_NAME + ' ' + L_NAME) AS NAME, PHONE_MOBILE AS MOBILE FROM CONTACTS", conContacts)
  14.         dtaContacts = New SqlDataAdapter
  15.         dtsContacts = New DataSet
  16.  
  17.         dtaContacts.SelectCommand = cmdContacts
  18.  
  19.         Try
  20.             conContacts.Open()
  21.             dtaContacts.Fill(dtsContacts, "CONTACTS")
  22.         Catch ex As Exception
  23.             MessageBox.Show(ex.Message.ToString)
  24.         Finally
  25.             conContacts.Close()
  26.         End Try
  27.  
  28.         lstContacts.DataSource = dtsContacts.Tables("CONTACTS")
  29.         lstContacts.DisplayMember = "NAME"
  30.         lstContacts.ValueMember = "MOBILE"
  31.     End Sub
  32.  
  33.     Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
  34.         frmSendSMS.txtTo.Text = txtNumberList.Text
  35.         Me.Close()
  36.     End Sub
  37.  
  38.     Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click, lstContacts.DoubleClick
  39.         For i As Integer = 0 To lstContacts.Items.Count - 1
  40.             If lstContacts.Items(i).Selected Then          'Error comes here
  41.                 txtNumberList.Text += lstContacts.Items(i).Text & ";"
  42.             End If
  43.         Next
  44.     End Sub
  45.  
  46.     Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
  47.         txtNumberList.Text = ""
  48.     End Sub
  49. End Class
  50.  
when i run the program it loads the values in to the listbox.but when i select a item and press the add button it gives an error (something about late-binding)

Error:
Missing Member Exception was unhandled
Public member 'Selected' on type 'DataRowView' not found.


please tell me how to fix this or is their a better way to do this?

chathura
Oct 18 '07 #1
4 2152
Shashi Sadasivan
1,435 Expert 1GB
could you please point to the line at which the error is thrown,
and be specific rather than "some kind of error" .. dosent help us anyways, and neither will it to you
Oct 18 '07 #2
chathura86
227 100+
could you please point to the line at which the error is thrown,
and be specific rather than "some kind of error" .. dosent help us anyways, and neither will it to you
Error is in the line 40 it is indicated with a comment also.
and the error message i'v got is mentioned under "Error:"

Thank you.
Oct 18 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
you mean to say that there is no other description of the error!!!!

could you please let us know what kind of datatype is "lstContacts"

It is not declared in the code sniuppet provided by you (Sorry if i missed the fine print amongst the haystack there)
Oct 18 '07 #4
chathura86
227 100+
you mean to say that there is no other description of the error!!!!

could you please let us know what kind of datatype is "lstContacts"

It is not declared in the code sniuppet provided by you (Sorry if i missed the fine print amongst the haystack there)
it's ok i should have mentioned line nuber cz it is bit hard to see.

Visual Studio 2005 givs the following tip:
***********************************************
if a member in a class library has been moved, recompile any assemblies that reference that library.
if you are atempting to access members on a late-bounded object variable, make sure it is declared public.
***********************************************

lstContact is ListBox which i draged and droped into the form. must say that im not very good with vb

is there a way to early bind this listbox. but may have to change the sql query on runtime to get different items to the listbox accoring to a query which can be typed on a textbox
Oct 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme...
0
by: MarionEll | last post by:
XML Conference 2003 program now available…register with discounts now! IDEAlliance has just released the full program for XML 2003 scheduled December 7-12 at the Philadelphia Convention Center....
0
by: melledge | last post by:
Deadline for XTECH 2005 Late-Breaking News and Vendor Presentations - 28 March The deadline for submission of Late-Breaking News and Vendor Presentations for IDEAlliance's XTCH 2005...
2
by: hazz | last post by:
how do I do this? I am certain my Visual Studio .NET solution allowed me to do this before but I don't know how the build/debug settings were configured. In order to get around an unavoidable...
1
by: Daniel | last post by:
How do I call a delegate in late bound C# dll? there some way to do this w/ a sharedinterface file? any examples? i tried this but it doesnt work: (oType.GetMethod("IOCTLJOB").Invoke(pObj, new...
1
by: jai | last post by:
I need to find the average number of days late for each supplier, each hav more than one order. how can i group the suppliers orders and find the average :S shud i do this in a report? i have...
32
by: whiteboy | last post by:
What's up Everyone? I really need some help. I've been pulling the hair out of my head trying to research how to calculate a late date. Here is what I'm trying to do: DATE VOUCHER...
1
snowman67
by: snowman67 | last post by:
I am writing an RFQ for a software to support my alternativecancer.us web site and need to add a late clause. I haven’t seen any, but I was thinking of a 1% penalty for the first week late and...
13
by: Wayne | last post by:
I have just experienced my first late paying client. By "late" I mean that the invoice is now almost 2 months overdue. I don't think that the client is maliciously withholding payment - rather...
0
by: efftronics | last post by:
Hi, My question is when i log on as a domain user in a computer, which is under domain i am getting very late. What are the reasons for that late. It takes more time for APPLYING YOUR PERSONAL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.