Friends , I have a database in sql server named "Deposit" with a table "Receipts" .I want to display the data in a list box.My code is given below

Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cnn As New SqlConnection("Data Source = (Local);Initial Catalog = Deposit;Integrated Security = True")
Dim cmd As New SqlCommand("Select * from Receipts", cnn)
Dim rdr As SqlClient.SqlDataReader
rdr = cmd.ExecuteReader
While rdr.Read
ListBox1.Items.Add(rdr("Bank") & " " & rdr("Acno"))
End While
End Sub
End Class

But on running Nothing happens.The mistake is in the connection statement, I think. please correct me. My computer name is "BENNET-PC" and Database is in Sql server Management Studio

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.