AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Stephen Jackson
Expertise
I can help with questions regarding VB.NET syntax and object references, with data interfaces and with the design and creation of robust, data aware object classes. I can also be very helpful with creating distributable applications and provide tricks and tips on .msi creation. I also have extensive experience in designing SQL Server Databases and interfacing them with VB.NET. I try to avoid web specific questions, as that is an area of expertise all its own.

Experience

Experience in the Area:
I have been a programmer in Visual Basic since version 1.0 and have worked with VB.NET (which is infinitely more powerful than previous versions) since its initial release and SQL Server, both as a corporate IT professional and professional consultant. I first wrote Basic in 1976 on a TRS 80 and have worked in Visual Basic 1.0 and every subsequent release of Microsoft Visual Basic. I worked for over 7 years as a Senior Level Consultant in the area and currently hold a Project Manager position in IT.

Education and Credentials:
MBA in Econometrics, 1983, University of Memphis. BBA in Financial Management, 1982, Fogelman College of Business and Economics, University of Memphis.
Microsoft Certified Professional

Areas of Special Expertise:
My specialty is the design of Object Oriented Solutions with robust, data aware object classes. I generally avoid the classic ‘Three Tier’ model as I find it redundant and cumbersome to maintain. I also specialize in the creation of ‘User Friendly’ User Interfaces which help lessen the need for user training and help prevent user error. I work best with Windows Forms based applications, and while I do work in C# as well, I prefer to limit my questions here to Windows Forms based applications created in Visual Basic.NET and SQL Server. I wil also address questions relating to the distribution and installation of Windows Forms based applications created in VB.NET.
 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > Run time Create Dataset-Databinding-Datagrid

Topic: VB.NET



Expert: Stephen Jackson
Date: 3/27/2008
Subject: Run time Create Dataset-Databinding-Datagrid

Question
Hi
I am getting error when i am running this code:
Outputwanted: I want to fetch the all data from a table & display in grid view in run time in VB.NET 2005
-----------------------
This is my code:
Imports System.Data.SqlClient
Public Class Form1

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim con As New SqlConnection
       con = New SqlConnection("Data Source=SYSTEM;Initial Catalog=trail;Integrated Security=True;Pooling=False")
       con.Open()

       Dim myds As DataSet = New DataSet("mydataset")
       Dim myadapter As SqlDataAdapter = New SqlDataAdapter("select * from table1", con)
       myadapter.Fill(myds, "table1")

       myadapter.TableMappings.Add("Table1", "textbox1")
       myadapter.Fill(myds)
       DataGrid1.DataSource = myds.DefaultViewManager

       DataGrid1.DataBindings.Add(New Binding("combo1", myds, "table1"))
       
   End Sub

when i run this code It generates an error in the last statement of the code (in databinding) also combo,text but none works:

"Cannot bind to the property 'combo1' on the target control.'Parameter name: PropertyName "  

Answer
Dear Newbie,

This is a rather different way of handling this than I have ever done (perhaps an example from Microsoft Press?) ... anyway, at first blush, my guess is that in utilizing the same data set for the combo binding as for the grid may e at the root of the problem.  I would try creating a new dataset specifically for the combo binding (combo boxes inside a grid will always be a headache!).

Make sure the combo box has the correct datafield and datatext properties to correlate with the recordset.  

If that does not help we will work on this farther.

Good luck!

Stephen  Jackson

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.