0

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.

2
  • 3
    there are many examples on the web: google.co.nz/…. Maybe you have a slightly more specific example of what you're trying to achieve. Commented Oct 6, 2009 at 9:36
  • What kind of database? SQL Server? Access? Commented Oct 6, 2009 at 10:06

2 Answers 2

2
 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..

Sign up to request clarification or add additional context in comments.

Comments

0

Samples here might work for you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.