1,105,409 Community Members

from database to listview

Member Avatar
pride123
Newbie Poster
3 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connection As New SqlClient.SqlConnection
        Dim command As New SqlClient.SqlCommand
        Dim adaptor As New SqlClient.SqlDataAdapter
        Dim dataset As New DataSet

        connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\korisnik\documents\visual studio 2010\Projects\WindowsApplication46\WindowsApplication46\Database2.mdf;Integrated Security=True;User Instance=True")
        command.CommandText = "SELECT * FROM [User] WHERE (username='" + TextBox1.Text + "')AND (password='" + TextBox2.Text + "');"

        command.Connection = connection
        adaptor.SelectCommand = command
        adaptor.Fill(dataset, "1")
        Dim count = dataset.Tables(0).Rows.Count)
        If count > 0 Then
            Form2.Show()
            Me.Hide()

        Else
            MsgBox("Bad username or password!!")

        End If
    End Sub

Now, I want the code in the loop if. actually when I press the button, and in the textbox is a number which coincides with the number in the database,then get the records from a database in a listview, how to do that?
something like this:

if textbox.text= fild in a database then

print the fild from database to listview

else msg("no item!")

end if

Member Avatar
pride123
Newbie Poster
3 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

anyone?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article