Oversæt access udtræk til SQL server udtræk
Hej jeg har gennem et stykke tid prøvet at over sætte mit factory lag fra access til sql. men det lykkes ikke rigtig.Mit dataaccess lag:
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Public Class DataAccess
Inherits System.Web.UI.Page
#Region "MS SQL data objecter"
Public Function GetDataSql(ByVal Domain As String, ByVal Username As String, ByVal Password As String, ByVal Timeout As Integer, ByVal SQL As String, ByVal Database As String) As DataTable
Dim objDS As New DataSet
Dim objConn As New SqlConnection("Server=" & Domain & "; Database=" & Database & ";UID=" & Username & ";Password=" & Password & ";Connect Timeout=" & Timeout)
Dim objDA As New SqlDataAdapter(SQL, objConn)
objDA.Fill(objDS)
objConn.Close()
Return objDS.Tables(0)
End Function
Public Sub ModifyDataSql(ByVal Domain As String, ByVal Username As String, ByVal Password As String, ByVal Timeout As Integer, ByVal SQL As String, ByVal Database As String)
Dim objConn As New SqlConnection("Server=" & Domain & "; Database=" & Database & ";UID=" & Username & ";Password=" & Password & ";Connect Timeout=" & Timeout)
Dim objCMD As New SqlCommand(SQL, objConn)
objConn.Open()
objCMD.ExecuteNonQuery()
objConn.Close()
End Sub
#End Region
#Region "MS SQL Express data objecter"
Public Function GetDataSqlExp(ByVal SQL As String) As DataTable
Dim objDS As New DataSet
Dim objConn As New SqlConnection("Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\PUBS.MDF; Integrated Security=True; Connect Timeout=30; User Instance=True")
Dim objDA As New SqlDataAdapter(Sql, objConn)
objDA.Fill(objDS)
objConn.Close()
Return objDS.Tables(0)
End Function
Public Sub ModifyDataSqlExp(ByVal SQL As String)
Dim objConn As New SqlConnection("Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\PUBS.MDF; Integrated Security=True; Connect Timeout=30; User Instance=True")
Dim objCMD As New SqlCommand(SQL, objConn)
objConn.Open()
objCMD.ExecuteNonQuery()
objConn.Close()
End Sub
#End Region
End Class
Her kommer så selve factory lagget:
Imports Microsoft.VisualBasic
Imports System.Data
Public Class NewsFac
Inherits System.Web.UI.Page
Dim _strDB As String = My.Request.PhysicalApplicationPath & "/App_Data/dbNews.mdb"
Public Function GetAllNews() As DataTable
Dim objData As New DataAccess
Return objData.GetData("SELECT * FROM tblNews order by fldDato", _strDB)
End Function
Håber virklig der er nogle der kan hjælpe mig :) På forhånd tak