快压

当前位置:首页 > 电脑技巧 > 正文

解决一个.NET联接SQL的问题

浏览次数:|更新日期:2015年04月16日

  Imports System.Data
  Imports System.Data.SqlClient
  Imports System.Data.SqlClient.SqlException
  Public Class connect
  Private s As String
  Private s1 As String
  Public Connect As New SqlConnection(“server=Yiyang;database=KDERP;uid=sa;password=123″”)
  Sub New()
  Connect.Open()
  End Sub
  Public Property sql()
  Get
  Return s
  End Get
  Set(ByVal Value)
  s = Value
  End Set
  End Property
  Public Property table()
   Get
   Return s1
   End Get
   Set(ByVal Value)
   s1 = Value
  End Property
  Public Function Retable() As DataTable
  Dim com As New DataSet()
  Dim ada As New SqlDataAdapter()
  Dim com1 As New SqlCommand()
  com1.Connection = Connect
  com1.CommandText = s
  ada.SelectCommand = com1
  ada.Fill(com