Question retrieve data from sql database

trialer

Well-known member
Joined
Oct 4, 2010
Messages
64
Programming Experience
1-3
How can i retrieve data from sql database and put the values in textboxes?
 
Please post each question once only and in the most appropriate forum. If you think you've posted in the wrong forum then contact the moderators and let them move it. I've deleted your other post in the Web Forms forum as your previous questions were for WinForms.

What you've asked for is a multi-stage process and the best option for each stage depends on exactly what you're trying trying to achieve. Please provide a more complete description.
 
Please post each question once only and in the most appropriate forum. If you think you've posted in the wrong forum then contact the moderators and let them move it. I've deleted your other post in the Web Forms forum as your previous questions were for WinForms.

What you've asked for is a multi-stage process and the best option for each stage depends on exactly what you're trying trying to achieve. Please provide a more complete description.




here's my code for retrieving

VB.NET:
Connect()
        Dim cmd As New SqlCommand ("SELECT * FROM table_subsprofile WHERE CustomerID = '" & txtCustomerID.Text & "'", con)
        Dim dr As SqlDataReader = cmd.ExecuteReader
        If dr.Read Then
            txtCitizenship.Text = dr("Citizenship")
            txtEmail.Text = dr("Email_Add")
            dtpDOB.Text = dr("Birthday")
            txtReg_Date.Text = dr("Reg_Date")
            txtInst_Date.Text = dr("Inst_Date")
            cboGender.Text = dr("Gender")
            txtAge.Text = dr("Age")
            txtContact.Text = dr("Contact_No")
            txtStat.Text = dr("Account_Stat")
            cboCS.Text = dr("Civil_Stat")
            cboPackage.Text = dr("Package")
            cboTitle.Text = dr("Title")
            txtAddress.Text = dr("Address")
        End If
        Disconnect()


i have no more problem with retrieving data from the database

my problem now is how can i get the lastname in the textbox which fullname in there..
 
Let's get this straight. You originally asked how to retrieve data from a database and display it in TextBoxes, but you actually already know how to do all that. The only thing you don't know how to do is break up a full name into the first and last name. Is that correct?
 
Let's get this straight. You originally asked how to retrieve data from a database and display it in TextBoxes, but you actually already know how to do all that. The only thing you don't know how to do is break up a full name into the first and last name. Is that correct?

yes sir,..
 
Was that the case when you created the thread in the first place or did you figure that part out afterwards?

Anyway, the full name is a String, presumably containing two names separated by a space, e.g. "John Smith". To split them up you would use the String.Split method, which returns a String array. The first name will be in the first element and the last name will be in the second element.

That said, if you need to use the names separately then they really should be stored separately.
 
Was that the case when you created the thread in the first place or did you figure that part out afterwards?

Anyway, the full name is a String, presumably containing two names separated by a space, e.g. "John Smith". To split them up you would use the String.Split method, which returns a String array. The first name will be in the first element and the last name will be in the second element.

That said, if you need to use the names separately then they really should be stored separately.


could you make a clear example of that split.string method.
for instance the name is "Smith, John Wesson T."
lastname = Smith
firstname = John Wesson
middle initial = T.
 
What did you not understand about the examples you found online when you searched? There's not much point my just reproducing something that's already available if you didn't understand that.
 
Back
Top