0

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
cnn.Open()
rdr = cmd.ExecuteReader
While rdr.Read
ListBox1.Items.Add(rdr("Bank") & " " & rdr("Acno"))
End While
rdr.Close()
cnn.Close()
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

2
Contributors
1
Reply
14
Views
3 Years
Discussion Span
Last Post by cgeier
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.