Vaibhav
Vaibhav

Reputation: 7008

how can we retrieve data from database in ASP.NET using VB as language?

i need the complete code for retreiving the data from a database.. i m coding in visual web developer and using VB as coding language. I m using SQL SERVER as database handler.

Upvotes: 0

Views: 2811

Answers (2)

maxy
maxy

Reputation: 438

 Shared Dim con As SqlConnection

Shared Sub Main()
    con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI") 

    ' Create the command object
    Dim str As String = "SELECT ID, FirstName, LastName FROM Employee"
    Dim cmd As New SqlCommand(str, con)

    Dim da As New SqlDataAdapter(cmd)

    Dim ds As New DataSet()

    da.Fill(ds, "Employee")

    gridview1.datasource=ds;//
     gridview1.databind();// to bind the data to gridview

its will be help to u..

Upvotes: 2

jerjer
jerjer

Reputation: 8766

Samples here might work for you

Upvotes: 0

Related Questions