473,471 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

two more noob questions sorry.



1. How do I pass a subroutine a reference of an object?

For example I have variable datef type datetime. I want to pass to pass
datef the variable, not it's value to the sub?
2. In ADO.NET, how can I see what the parsed value of of a SQL command
is after @parameters have been passed in?
Thank you!

Jan 24 '07 #1
4 1081


On Jan 24, 10:38 am, "jobs" <j...@webdos.comwrote:
1. How do I pass a subroutine a reference of an object?

For example I have variable datef type datetime. I want to pass to pass
datef the variable, not it's value to the sub?
The ByRef keyword. Use it in the function's parameter list:
Public Function myFunc(ByRef something As Object)
......
......
End Function

ByVal is the default, for passing by value

Jan 24 '07 #2
2. In ADO.NET, how can I see what the parsed value of of a SQL command
is after @parameters have been passed in?
Not sure what you mean here, are you looking for the values returned
when the command executes? If so do this:

Dim com As New SqlClient.SqlCommand()
' Do whatever you need to with the command (set parameters,
active connection, etc)
Dim dr As SqlClient.SqlDataReader = com.ExecuteReader()

While (dr.Read())
Console.WriteLine(dr.GetString(0)) ' Replace 0 with
whichever field you need
End While

If not, please try to explain what you are looking for a little better
and we'll try to help.

Thanks,

Seth Rowe
On Jan 24, 10:38 am, "jobs" <j...@webdos.comwrote:
1. How do I pass a subroutine a reference of an object?

For example I have variable datef type datetime. I want to pass to pass
datef the variable, not it's value to the sub?

2. In ADO.NET, how can I see what the parsed value of of a SQL command
is after @parameters have been passed in?

Thank you!
Jan 24 '07 #3
Thank you.

On Jan 24, 11:13 am, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
If not, please try to explain what you are looking for a little better
and we'll try to help.
I'm struggling with dates and ado. I have a sub that will be used to
update both strings and date fields in a table, and so I want the
field name in question to be dynamic. So the field type might be string
or datetime. I'm trying to avoid overloading the sub if possible. The
string update logic works fine, but I try to use it for dates I get
this error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and
12/31/9999 11:59:59 PM.
here's the sub:
Public Sub UpdateJob(ByVal Jobno As Integer, ByVal field As String,
ByVal Value As Object)
...
SQL = "Update job set " + field + "= @datef where jobno =
@jobno"
cmd.Parameters.Add("@datef", SqlDbType.DateTime).Value =
CType(Value, DateTime)
...
Dim numrow As Integer = cmd.ExecuteNonQuery

when it fails, the sub is called as follows

UpdateJob(jobno, datef) ... where datef is a datetime field I got
back from a stored proceddure output.

datef resolves to :2007-01-24 11:15:06.000 and when I do this manually

Update job set enddate='2007-01-24 11:15:06.000' where jobno = 2

it works.

but if I datef.tostring I get some string with AM / PM which does not
work.

and want to see the exact SQL that is being attempted.

Jan 24 '07 #4
<lo*********@gmail.comha scritto nel messaggio
>1. How do I pass a subroutine a reference of an object?

For example I have variable datef type datetime. I want to pass to pass
datef the variable, not it's value to the sub?

The ByRef keyword.
Pay attention: DateTime is a Value Type, as all the base types and
structures (except strings that is something different).

Reference types (classes) are *always* passed byref and specifying ByRef you
are making a double indirection of the pointer (the pratical effect is the
same).


Jan 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: administrata | last post by:
Hi! I'm programming maths programs. And I got some questions about mathematical signs. 1. Inputing suqare like a * a, It's too long when I do time-consuming things. Can it be simplified? 2....
7
by: administrata | last post by:
Is it possible? I tried... I = "John" print \ """ I used to love pizza"""
8
by: Ivan Shevanski | last post by:
Alright heres another noob question for everyone. Alright, say I have a menu like this. print "1. . .Start" print "2. . .End" choice1 = raw_input("> ") and then I had this to determine what...
7
by: dllhell | last post by:
hello all, would you like to explain what's mean "int?" I have find it in funcion declarations but in msdn I can't find anything useful by typing "int?" (msdn reurns everithing where "int"...
0
by: webmaster | last post by:
I've been playing around with asp.net 2.0/vs.net 2005/C# 2005 - I had a few noob questions. 1. Is there a setting that sets all current and future controls on a page to position absolutely...
0
by: webmaster | last post by:
I've been playing around with asp.net 2.0/vs.net 2005/C# 2005 - I had a few noob questions. 1. Is there a setting that sets all current and future controls on a page to position absolutely...
4
by: jobs | last post by:
Three noob questions. Please help. 1. Is there a way to have arguments on subroutine that are optional? 2. Say I need to convert datetime to string..in this format : 2006-09-07...
5
by: Milan Krejci | last post by:
the thing is that descentant branches i dont want to expand do expand. $id variable contains an array of branches i want the program to go through (alcohol's id -beer id etc) function...
9
by: Ben | last post by:
Hello, I'll bet this has been asked a million times but I can't seem to find a thread that gives the clear example I need. This PC has MySQL and IIS configured and running. The MySQL database is...
2
by: Carnell, James E | last post by:
I am thinking about purchasing a book, but wanted to make sure I could get through the code that implements what the book is about (Artificial Intelligence a Modern Approach). Anyway, I'm not a...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.