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 > showing and deletion in vb.net

Topic: VB.NET



Expert: Stephen Jackson
Date: 4/22/2008
Subject: showing and deletion in vb.net

Question
Hi,

I have two tables person and legnresp which are having personid as common field.Person table is parent and legnresp is child. i want to delete related record in legnresp so i made a form and do following coding in ComboBox1_SelectedIndexChanged as i want that while selecting combobox i get personid of both table but its showing error it is showing from person table but my question is how to show related record in textbox4.text from legnresp

Note:- without using cascade i want to do.

Dim sqlconn As New SqlConnection("data source=TBPC25\SQLEXPRESS;Initial Catalog=RealEstate1;Integrated Security=True")
       sqlconn.Open()

       cmd = New SqlCommand("select firstname from person where firstname='" & ComboBox1.Text & "'", sqlconn)
       cmd2 = New SqlCommand("select personid from person where firstname='" & ComboBox1.Text & "'", sqlconn)
       cmd3 = New SqlCommand("select personid from legnresp person where personid='" & TextBox3.Text & "'", sqlconn)
       'cmd3 = New SqlCommand("select personid from person legnresp where personid.person = personid.legnresp", sqlconn)
       'Dim ra As Integer

       dr = cmd.ExecuteReader()
       If dr.read Then
           TextBox1.Text = Trim(dr(0))

       End If
       sqlconn.Close()
       sqlconn.Open()

       dr2 = cmd2.ExecuteReader
       If dr2.Read Then
           TextBox3.Text = Trim(dr2(0))
       End If
       sqlconn.Close()
       sqlconn.Open()
       dr3 = cmd3.ExecuteReader
       ' If dr3.Read Then
       TextBox4.Text = TextBox3.Text

       'End If



when i do textbox4.text=textbox3.text it always shows whatever present in textbox3 which i don't want how to show
("select personid from person legnresp where personid.person = personid.legnresp") in textbox4 while selecting personid from combobox it show related record of personid in tetbox4.

After showing it i want to delete particular record which i want.


Hope you understand what i want to explain and do the needful to help me in this.


Thanks
Sukhvinder


Answer
Sukhvinder,

If I understand correctly, you want to select a person in the combo box, display their first name in textbox1.  Then you want to select the personid which relate to this person and place this value in textbox3, and then query the related records for this person from legnresp ,then be able to select a record from textbox3 and delete that record?.

Assuming I am right, I think you need to use a grid control to return the recordset from legnresp so you can select, but to get the related records to show should be simple enough ... just change

 TextBox4.Text = TextBox3.Text

to

 TextBox4.Text = Trim(dr3(0))

This way, you are actually showing the records you wanted to see.  Now I have never tried to place a recordset in a text box .. it might work.

Stephen

[PS: this looks a lot like a homework question to me, which I usually do not answer, but I figured I would give this a try ;c)]


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.