is there any other way to do this?
There are a number of ways to do this, but we can't tell what "any other" would be before letting us know which is the one you are using.
If the data in the 2 tables share keys and make sense to join them you can join the tables and use 1 connection to retrieve them.
If the 2 tables cannot or should not be joined then you can use 2 separate connections and query the db or you can recycle your connection and datareader or command or whatever to read the data from the second table.
Please share the code you've used and have problems with in order to find the error and help you.
For you to understand better, I have a listview (listview.jpg) where the table I'm using to retrieve the data is accounting_system. When I doubleclick on a student another form will show showing the retrieved student no from accounting system (newstudform.jpg) I only need to retrieve the student no from the accouting system, because the rest of the student info is stored in the temp_student_info.
The way its like this is bec in the process of enrollment, its the accounting(the last step) who's creating the student id. after that what we did is we will just retrieve the created student no from the accounting and retrieve the other information of the student stored in the temp_student_info and then save it all in the permanent database of the students.
This is my code for retrieving the accouting_system in the newstudform.
Sub retrieve() Try strsql = "select * from accounting_system where Student_No = @field1" sqlcmd = New SqlClient.SqlCommand(strsql) sqlcmd.CommandText = strsql sqlcmd.Connection = sqlconn sqlda.SelectCommand = sqlcmd With sqlcmd .Parameters.AddWithValue("@Field1", txtstud_no.Text) End With sqldr = sqlcmd.ExecuteReader sqlcmd.Dispose() sqldr.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
and this is the code i used to retrieve the temp_student_info
Sub retrievestud() Try strsql = "select * from temp_student_info where TempStudNo = @field1" sqlcmd = New SqlClient.SqlCommand(strsql) sqlcmd.CommandText = strsql sqlcmd.Connection = sqlconn sqlda.SelectCommand = sqlcmd With sqlcmd .Parameters.AddWithValue("@Field1", txttempstudno.Text) End With sqldr = sqlcmd.ExecuteReader If (sqldr.Read()) Then txtsurname.Text = (sqldr("Surname")) txtfirstname.Text = (sqldr("First_Name")) txtmiddlename.Text = (sqldr("Middle_Name")) End If sqlcmd.Dispose() sqldr.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Oh no no, I just solved it. Haha. Right after I replied XD
Thank you anyway :D
Nooo! I take it back! *.*
Yes, it's retrieving BUT it only retrieves the first data in my temp_student_info.
the data from accounting system is fine.
please help >.<
What is the value for txttempstudno.Text ?
How do you get it populated?
In my mind this is done by adding a variable in newstudform and on load query the db with that variable as ID. In your listview double click event you call the newstudform, passing as variable the ID of the current row.
Since you've succeeded in retrieving only the first user from your temp_student_info table, I'm guessing that you've removed the criteria from your retrievestud query, which is wrong.
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Hello All ...
Iam Getting An Error With try to excecute the stored procedure .
I have Have Sql database , the stored procedure like so :
USE [MPRS] GO /****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Here is the sample output that I ...