i have a table in database name user (username,userid,country). i want to retrieve the data in asp.net. but i have problem in connecting sql database. this is my code
Public Sub connect()
Dim DatabaseName As String = "user"
Dim server As String = "loalhost"
Dim userName As String = "me"
Dim password As String = " "
If Not conn Is Nothing Then conn.Close()
conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, userName, password, DatabaseName)
End Sub
i try this to retrieve the data using this code but error
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
conn.Open()
Catch ex As Exception
End Try
Dim cmd As New SqlCommand(String.Format("SELECT username FROM user"))
cmd.ExecuteNonQuery()
conn.Close()
End Sub