kcwallace
Centurion
I have the following VB.NET class. Its function is to simplify database interaction. I want to create a web service to do the same thing for my web application, and to avoid multiple copies of the code residing on the intranet. My problem is, how do I pass constants from the web service to ASP.NET project?
Visual Basic:
Imports System.Data
Imports System.Data.SqlClient
Public Class ADONET
Public Const CnnStrDosimSQL As String = "Data Source=process;Initial Catalog=dosimetrysqldatabases;Integrated Security=SSPI;"
Public Const CnnStrIT As String = "Data Source=process;Initial Catalog=IT;Integrated Security=SSPI;"
Public Const CnnStrSQA As String = "Data Source=process;Initial Catalog=SQA;Integrated Security=SSPI;"
Public Const CnnStrHR As String = "Data Source=process;Initial Catalog=HR;Integrated Security=SSPI;"
Public Const CnnStrDosimSQLWeb As String = "server=PROCESS;database=dosimetrysqldatabases;UID=sa;PWD=sa;"
Public Const CnnStrHRWeb As String = "server=PROCESS;database=HR;UID=sa;PWD=sa;"
Public Const CnnStrSQAWeb As String = "server=PROCESS;database=SQA;UID=sa;PWD=sa;"
Public Const CnnStrITWeb As String = "server=PROCESS;database=IT;UID=sa;PWD=sa;"
Public Function SetCnn(ByVal CnnStr As String) As SqlConnection
SetCnn = New SqlConnection(CnnStr)
SetCnn.Open()
End Function
Public Function GetDR(ByVal SQL As String, ByVal Cnn As SqlConnection) As SqlDataReader
If Cnn.State = ConnectionState.Open Then
Cnn.Close()
Cnn.Open()
End If
Dim Cmd As SqlCommand = GetCmd(SQL, Cnn)
GetDR = Cmd.ExecuteReader
End Function
Public Function GetDA(ByVal Cmd As SqlCommand, ByRef DS As DataSet) As SqlDataAdapter
GetDA = New SqlDataAdapter
GetDA.SelectCommand = Cmd
DS = New DataSet("X")
GetDA.Fill(DS)
End Function
Public Function GetCmd(ByVal SQL As String, ByVal Cnn As SqlConnection) As SqlCommand
GetCmd = New SqlCommand(SQL, Cnn)
End Function
Public Sub ActionSQL(ByVal SQL As String, ByVal Cnn As SqlConnection)
Dim Cmd As SqlCommand = GetCmd(SQL, Cnn)
Cmd.CommandText = SQL
Cmd.ExecuteNonQuery()
End Sub
end class