| | |
Retreiving data from previous form to next form
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Hi All,
I am working on a windows application in vb.net. (School Management Project).
My problem is that, when I am adding the Personal Details of a student,(which include enrolmentno(primary key in the database),name,class,section,etc), when I click the save button what I want is that the enrolmentno should appear on the ParentDetail Form without again entering it. (later that would be used as a foreign key to the PARENTDETAIL table in the database), but I am not able to get the value of enrolmentno from my previous form to the next form.
I declared the variable as Public in the PersonalDetail Form and then tried to access that variable in the ParentDetail Form by instantiating the object of the previous form, but that doesnt work.
I also tried to get the value of enrolmentno from the database using the ExecuteRead command. but I couldn't findout how to retrieve the last entered columns field using ExecuteRead.
'but this enters the value of the first record int the database.
I am new to VB.Net. Please Help. I hope my problem is clear.
Thanks.
I am working on a windows application in vb.net. (School Management Project).
My problem is that, when I am adding the Personal Details of a student,(which include enrolmentno(primary key in the database),name,class,section,etc), when I click the save button what I want is that the enrolmentno should appear on the ParentDetail Form without again entering it. (later that would be used as a foreign key to the PARENTDETAIL table in the database), but I am not able to get the value of enrolmentno from my previous form to the next form.
I declared the variable as Public in the PersonalDetail Form and then tried to access that variable in the ParentDetail Form by instantiating the object of the previous form, but that doesnt work.
VB.NET Syntax (Toggle Plain Text)
Public Class PersonalDetail Public enrolmentno As Integer .... End Class .... Public Class ParentDetail Public Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click Dim obj As New PersonalDetail Dim _enrol As Integer ... _enrol = obj.enrolmentno ' this shows the value 0 in the form .... End Sub .... End Class
I also tried to get the value of enrolmentno from the database using the ExecuteRead command. but I couldn't findout how to retrieve the last entered columns field using ExecuteRead.
VB.NET Syntax (Toggle Plain Text)
Dim dr As SqlDataReader Dim er As Integer Dim cmd1 As SqlCommand con = New SqlConnection("Server=localhost;" & "DataBase=SCHOOL;" & "Integrated Security=SSPI") cmd1 = New SqlCommand("SELECT * FROM PERSONALDETAIL ", con) dr = cmd1.ExecuteReader While dr.Read _er = dr.GetInt32(0) _enrol = er End While dr.Close() End Sub
I am new to VB.Net. Please Help. I hope my problem is clear.
Thanks.
Regards,
Piya:)
Piya:)
Here, I have two froms:
Form1
Form2
Form1
VB.NET Syntax (Toggle Plain Text)
public Class Form1 public dataForm1 as Integer ...... Sub button1_click(..) Form2.dataForm2=10 Form2.Show() End Sub End Class
Form2
VB.NET Syntax (Toggle Plain Text)
public Class Form2 public dataForm2 as Integer ...... Sub button1_click(..) MsgBox("Data from Form1 " & dataForm2) Form1.dataForm1=20 Form1.Label1.Text="Test" End Sub End Class
Last edited by adatapost; Jul 3rd, 2009 at 10:09 am.
Failure is not fatal, but failure to change might be. - John Wooden
For the latter approach
use
in your insert statement. See Save binary data to SQL Server with VB.NET in my blog for a more complete example.
•
•
•
•
I couldn't findout how to retrieve the last entered columns field using ExecuteRead
VB.NET Syntax (Toggle Plain Text)
Dim oCmd As SqlCommand . . strSQL = "INSERT INTO <table> (<fields>) VALUES (<values>)" strSQL = strSQL & "; SELECT @@IDENTITY AS 'Identity' " oCmd.CommandText = strSQL NewIdentity = CInt(oCmd.ExecuteScalar())
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- Please help with passing data from one form to another form (VB.NET)
- Help!! Form Sends Incomplete Data Should Be Required To submit Form (PHP)
- Retreiving Data from MS Access (VB.NET)
- retreiving data onto a combo box on VB form. (VB.NET)
- help: retrieve data from a XML file into a vb form (Visual Basic 4 / 5 / 6)
- load data from access database into form (VB.NET)
- submiting info into a database for retrieval! (PHP)
- Moving <form></form> to an external file? (HTML and CSS)
Other Threads in the VB.NET Forum
- Previous Thread: Regular Expressions Vb.Net
- Next Thread: SQL
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dropdownlist excel fade file-dialog folder ftp generatetags google gridview hardcopy image images input insert intel internet mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf






