2009-10-06 65 views
0

我需要從數據庫中提取數據的完整代碼。我在可視化Web開發人員中編寫代碼並使用VB作爲編碼語言。我使用SQL SERVER作爲數據庫處理程序。如何使用VB作爲語言在ASP.NET中從數據庫檢索數據?

+3

有在網絡上很多例子:http://www.google.co.nz/search?rlz=1C1GGLS_enNZ329NZ329&sourceid=chrome&ie = UTF-8&q = vb.net + ado.net。也許你有一個稍微更具體的例子,說明你想要達到的目標。 – 2009-10-06 09:36:20

+0

什麼樣的數據庫? SQL Server?訪問?數據庫在SQL SERVER上的 – Kramii 2009-10-06 10:06:46

+0

.. – Vaibhav 2009-10-06 10:11:27

回答

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 

其將到u幫助..

相關問題