Expand|Select|Wrap|Line Numbers
- Partial Public Class clsSQL
- Inherits MarshalByRefObject
- Dim DisSqlConn As SqlConnection
- Sub main()
- Dim channel As TcpServerChannel = New TcpServerChannel(1234)
- ChannelServices.RegisterChannel(channel, False)
- End Sub
- Public Function connectToDB()
- Dim sysInfo As New clsConnection
- Dim sqlUserName As String
- Dim sqlPassWord As String
- Dim SqlConnString As String
- 'set Username and Password for SQL Connection
- sqlUserName = sysInfo.SQLUserName
- sqlPassWord = sysInfo.SQLPassWord
- 'initialize connection string
- SqlConnString = "server=dissql;uid=" + sqlUserName + ";pwd=" + sqlPassWord + ";database=dis"
- DisSqlConn = New SqlConnection(SqlConnString)
- 'open the connection string
- Try
- DisSqlConn.Open()
- Catch ex As Exception
- Dim errorString As String = "error: "
- errorString = errorString + ex.Message
- MsgBox(errorString, MsgBoxStyle.Critical, )
- End Try
- End Function
- Public Function getCaseScreenInfo(ByVal caseNumber As String) As String()
- Dim caseCommand As SqlCommand
- Dim caseString As String
- Dim drCase As SqlDataReader = Nothing
- Me.connectToDB()
- caseString = "select CASE_RECORD.CASE_NUMBER,CASE_RECORD.CASE_DESCRIPTION," _
- & "CASE_RECORD.CASE_STATUS_CODE,CASE_RECORD.CASE_INDUSTRY_CODE," _
- & "CASE_RECORD.CASE_PURPOSE_CODE,CASE_RECORD.CASE_OPENED_DATE," _
- & "CASE_RECORD.CASE_DATE_CLOSED from dbo.CASE_RECORD" _
- & " where CASE_RECORD.CASE_NUMBER='" & caseNumber & "'"
- caseCommand = New SqlCommand(caseString, DisSqlConn)
- Try
- drCase = caseCommand.ExecuteReader()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- Dim caseValues(drCase.FieldCount) As String
- If drCase.HasRows Then
- While drCase.Read
- Dim i As Integer = drCase.FieldCount
- Dim i2 As Integer = 0
- While i >= 1
- caseValues(i2) = drCase(i2)
- i = i - 1
- i2 = i2 + 1
- End While
- End While
- Return caseValues
- End If
- End Function
- Public Function closeDB()
- Try
- DisSqlConn.Close()
- DisSqlConn = Nothing
- Catch ex As Exception
- MsgBox("error: " + ex.Message, MsgBoxStyle.OkOnly, )
- End Try
- End Function
- End Class
Expand|Select|Wrap|Line Numbers
- Imports System.Runtime.Remoting
- Imports System.Runtime.Remoting.Channels
- Imports System.Runtime.Remoting.Channels.Tcp
- Imports DISCLSV100
- Module modRemoteConn
- Sub Main()
- Dim channel As TcpServerChannel = New TcpServerChannel(49152)
- ChannelServices.RegisterChannel(channel, False)
- RemotingConfiguration.RegisterWellKnownServiceType(GetType(DISCLSV100.clsSQL), "clsSQL", WellKnownObjectMode.SingleCall)
- Console.WriteLine("Server Started")
- Console.WriteLine("Hit <enter> to quit")
- Console.ReadLine()
- End Sub
- End Module
Expand|Select|Wrap|Line Numbers
- Dim childCases As New frmCases
- Dim caseChannel As TcpClientChannel = New TcpClientChannel()
- ChannelServices.RegisterChannel(caseChannel, False)
- RemotingConfiguration.RegisterWellKnownClientType(GetType(clsSQL), "tcp://jackie:49152/dbconnect")
- dbc = New clsSQL
- Dim information() As String
- information = dbc.getCaseScreenInfo(Me.mtxtCaseNum.Text)
thanks Jackie