M
Mike Hoff
I am trying to write a class that will store info about database fields for
building UPDATE / INSERT commands later on. I cannot seem to get the sytax
correct to pass and store the data type of the field. My class looks like:
Public Class DataTag
Private m_Text As String
Private m_FieldName As String
Private m_ParamName As String
Private m_DataType As System.Type 'the variable type of this field
Public Sub New(ByVal sText As String, ByVal sField As String, ByVal sParam
As String, ByVal typeData As System.Type)
m_Text = sText
m_FieldName = sField
m_ParamName = sParam
m_DataType = typeData
End Sub
When I try to define an object with:
txtName.Tag = New DataTag(txtName.Text, "Name", "@Name", System.String)
System.String shows error: 'String' is a type in 'System' and cannot be used
in an expression. I have also tried using a GetType property on a string,
but that has failed also. How can I pass and store the data type of the
field? I want to do this so that I can later loop through the text boxes
and do something like...
MySQLCommand.Parameters.Add(dataTagCurrent.paramName,
dataTagCurrent.DataType).Value = txtLoop.Text
Or something similar based on the control/data type, and also build the SQL
Command string.
Any help appreciated - thanks,
Mike
building UPDATE / INSERT commands later on. I cannot seem to get the sytax
correct to pass and store the data type of the field. My class looks like:
Public Class DataTag
Private m_Text As String
Private m_FieldName As String
Private m_ParamName As String
Private m_DataType As System.Type 'the variable type of this field
Public Sub New(ByVal sText As String, ByVal sField As String, ByVal sParam
As String, ByVal typeData As System.Type)
m_Text = sText
m_FieldName = sField
m_ParamName = sParam
m_DataType = typeData
End Sub
When I try to define an object with:
txtName.Tag = New DataTag(txtName.Text, "Name", "@Name", System.String)
System.String shows error: 'String' is a type in 'System' and cannot be used
in an expression. I have also tried using a GetType property on a string,
but that has failed also. How can I pass and store the data type of the
field? I want to do this so that I can later loop through the text boxes
and do something like...
MySQLCommand.Parameters.Add(dataTagCurrent.paramName,
dataTagCurrent.DataType).Value = txtLoop.Text
Or something similar based on the control/data type, and also build the SQL
Command string.
Any help appreciated - thanks,
Mike