【问题标题】:how can we retrieve data from database in ASP.NET using VB as language?我们如何使用 VB 作为语言从 ASP.NET 中的数据库中检索数据?
【发布时间】:2010-12-04 05:13:53
【问题描述】:

我需要从数据库中检索数据的完整代码。我在可视化 Web 开发人员中进行编码并使用 VB 作为编码语言。我正在使用 SQL SERVER 作为数据库处理程序。

【问题讨论】:

  • 网上有很多例子:google.co.nz/…。也许你有一个更具体的例子来说明你想要实现的目标。
  • 什么样的数据库? SQL 服务器?访问?

标签: asp.net vb.net data-access-layer


【解决方案1】:
 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

它会对你有所帮助..

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-28
    • 1970-01-01
    • 2017-03-06
    • 2019-02-19
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多