is this the way to program in classes? or ......
I am not used to programming win classes, yes I am a newbie :-x in classes
(windows app, SQL database, VB.studio net v2003)
I used the following code to get a connection string wich is located in
an XML-file.
I cannot do this in a form_open_event because the classes are triggered
before any action takas place in opening/activating the form, wich results in error,
because there is no connection string.
The code puts the connection string to a modal declared string (m_connString),
in the class.
SO, I put the code in the class, right below the my base new.....blabla
IS this the right way to do, or is there a wiser method to get data into
a class?
*****************************************************
Here is de coding:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Option Explicit On
Imports System.Data.SqlClient
Imports System.Xml.Serialization
Imports System.IO
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Public Class DataServiceSQL
Private m_connString As String
Private m_con As SqlConnection
Friend WithEvents m_da As New SqlDataAdapter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Public Sub New()
Dim p As New XML
Dim x As New XmlSerializer(p.GetType)
Dim objStreamReader As New StreamReader("D:\Documents and Settings\Administrator\Mijn documenten\Visual Studio Projects\WindowsApplication49\DMS.xml")
Dim p2 As New XML
p2 = x.Deserialize(objStreamReader)
objStreamReader.Close()
m_connString = p2.strMyConn
m_con = New SqlConnection(m_connString)
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Public Property GetConnString() As String
Get
Return m_connString
End Get
Set(ByVal Value As String)
m_connString = Value
End Set
****************************************************
Have a day,
reinier:wave:
is this the way to program in classes? or ......
HI Craig,
Of course we are all free in implementing our prgram codes,
but because this (class programming) is new to me, there
might be a neater more efficiant way of programming.
There is more in the class, the coding I showed was only
for retrieving the connection string from a xml file.
More in this class is for receiving the dataset, receiving
update,delete and insert commands for the dataadapter.
(nothing special)
regards,
reinier
:wave:
is this the way to program in classes? or ......
Thanks Craig!
I did look onto it very quikly,
I looks very promising.
Do you know by change, if this is a way
a sending data from a module to a class?
Regards,
reinier:wave:
is this the way to program in classes? or ......
T H A N K S
reinier:wave: