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.paramNa me,
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 6 1977
Is this not working for you?
txtName.Tag = New DataTag(txtName.Text, "Name", _
"@Name", GetType(System.String))
Imran.
"Mike Hoff" <mi**@home.com> wrote in message
news:10*************@corp.supernews.com... 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.paramNa me, 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
Hi Mike,
Instead of Private m_DataType As System.Type
Try: Private m_DataType as Integer
Then when you pass to the function use SqlDbType.VarChar or whatever type it
is you are using. SqlDbType is just a class that holds Constants. Remember
to import System.Data.SqlClient wherever you use it. Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Mike Hoff" <mi**@home.com> wrote in message
news:10*************@corp.supernews.com... 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.paramNa me, 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
Thanks for responses - using Integer worked like a charm.
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:uv****************@TK2MSFTNGP09.phx.gbl... Hi Mike,
Instead of Private m_DataType As System.Type
Try: Private m_DataType as Integer
Then when you pass to the function use SqlDbType.VarChar or whatever type
it is you are using. SqlDbType is just a class that holds Constants.
Remember to import System.Data.SqlClient wherever you use it. Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Mike Hoff" <mi**@home.com> wrote in message news:10*************@corp.supernews.com... 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.paramNa me, 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
Hi Mike and Ken,
I had a similar question and was hoping that either of you could help me. It
is probably a dumb queston but I was trying to determine the type of column
coming back from a resultset to format a date but I don't know what to
compare it to for the type.
I was hoping to do this
If MySqlDataReader.GetFieldType(0) = <DATETIME constant>
trying SqlDbType types and GetType() on the RHS with no luck.
Thanks for your time
Regards
Amelia
"Mike Hoff" wrote: Thanks for responses - using Integer worked like a charm.
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message news:uv****************@TK2MSFTNGP09.phx.gbl... Hi Mike,
Instead of Private m_DataType As System.Type
Try: Private m_DataType as Integer
Then when you pass to the function use SqlDbType.VarChar or whatever type it is you are using. SqlDbType is just a class that holds Constants. Remember to import System.Data.SqlClient wherever you use it. Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Mike Hoff" <mi**@home.com> wrote in message news:10*************@corp.supernews.com... 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.paramNa me, 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
Hi Amelia,
There are a couple ways you can do this. The first is instead of using
GetFieldType() use:
MySqlDataReader.GetDataTypeName(0)
This will return a string of the data type the field contains. For example
and Integer = 'int'. Another way to test for a date is to test against the
actual field:
If (IsDate(MySqlDataReader("DateField")) Then
....process as date
End If
Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Amelia" <Am****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com... Hi Mike and Ken,
I had a similar question and was hoping that either of you could help me.
It is probably a dumb queston but I was trying to determine the type of
column coming back from a resultset to format a date but I don't know what to compare it to for the type.
I was hoping to do this
If MySqlDataReader.GetFieldType(0) = <DATETIME constant>
trying SqlDbType types and GetType() on the RHS with no luck.
Thanks for your time Regards Amelia
"Mike Hoff" wrote:
Thanks for responses - using Integer worked like a charm.
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message news:uv****************@TK2MSFTNGP09.phx.gbl... Hi Mike,
Instead of Private m_DataType As System.Type
Try: Private m_DataType as Integer
Then when you pass to the function use SqlDbType.VarChar or whatever
type it is you are using. SqlDbType is just a class that holds Constants. Remember to import System.Data.SqlClient wherever you use it. Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Mike Hoff" <mi**@home.com> wrote in message news:10*************@corp.supernews.com... > 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.paramNa me, > 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 > >
Hi Ken,
Thanks so much for your help and time - it really saved my bacon! Still
trying to work my way around .Net but determined to know all the classes soon
AND how to use them!
:0)
Amelia
"Ken Dopierala Jr." wrote: Hi Amelia,
There are a couple ways you can do this. The first is instead of using GetFieldType() use:
MySqlDataReader.GetDataTypeName(0)
This will return a string of the data type the field contains. For example and Integer = 'int'. Another way to test for a date is to test against the actual field:
If (IsDate(MySqlDataReader("DateField")) Then ....process as date End If
Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
"Amelia" <Am****@discussions.microsoft.com> wrote in message news:A8**********************************@microsof t.com... Hi Mike and Ken,
I had a similar question and was hoping that either of you could help me. It is probably a dumb queston but I was trying to determine the type of column coming back from a resultset to format a date but I don't know what to compare it to for the type.
I was hoping to do this
If MySqlDataReader.GetFieldType(0) = <DATETIME constant>
trying SqlDbType types and GetType() on the RHS with no luck.
Thanks for your time Regards Amelia
"Mike Hoff" wrote:
Thanks for responses - using Integer worked like a charm.
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message news:uv****************@TK2MSFTNGP09.phx.gbl... > Hi Mike, > > Instead of Private m_DataType As System.Type > > Try: Private m_DataType as Integer > > Then when you pass to the function use SqlDbType.VarChar or whatever type it > is you are using. SqlDbType is just a class that holds Constants. Remember > to import System.Data.SqlClient wherever you use it. Good luck! Ken. > > -- > Ken Dopierala Jr. > For great ASP.Net web hosting try: > http://www.webhost4life.com/default.asp?refid=Spinlight > > "Mike Hoff" <mi**@home.com> wrote in message > news:10*************@corp.supernews.com... > > 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.paramNa me, > > 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 > > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt |
last post by:
In ASP, when we pass data between pages, we usually pass by query string. If
we pass data by query string, that means we need to use submit button, not
by regular button, and the form will pass to...
|
by: Jenny |
last post by:
Hi,
I have a class foo which will construct some objects in my code. some
of the objects store int values into the data deque, while others
store float values to the deque.
template <class...
|
by: Dan |
last post by:
Can anyone offer suggestions on how to do this or if it is possible?
I have a form that uses a drop down box and 2 text fields.
What I am trying to do is have the value of each text box set by...
|
by: Jason Huang |
last post by:
Hi,
In Global.cs, I have public string myString="".
Another 2 forms are Form1.cs, Form2.cs.
How do I use the Global.cs' myString to store a string in Form1 and then
pass to Form2?
Thanks for...
|
by: Alan Silver |
last post by:
Hello,
I'm a bit surprised at the amount of boilerplate code required to do
standard data access in .NET and was looking for a way to improve
matters. In Classic ASP, I used to have a common...
|
by: Andy |
last post by:
Hi,
I have a complicated question that I'm hoping someone can help me out
with. I have a webpage that contains a plug-in. This plug-in can
communicate/pass data with the webpage that contains it...
|
by: jadeivel756 |
last post by:
I BADLY NEED YOUR HELP......
HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C.
My problem is that as I exit the...
|
by: jadeivel756 |
last post by:
I BADLY NEED YOUR HELP......
HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C.
My problem is that as I exit the...
|
by: =?Utf-8?B?U3dhcHB5?= |
last post by:
Can anyone suggest me to pass more parameters other than two parameter for
events like the following?
Event:
Onbutton_click(object sender, EventArgs e)"
Event handler:
button.Click += new...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |