473,809 Members | 2,687 Online
Bytes | Software Development & Data Engineering Community
+ 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 1100


On Jan 24, 10:38 am, "jobs" <j...@webdos.co mwrote:
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.SqlCo mmand()
' Do whatever you need to with the command (set parameters,
active connection, etc)
Dim dr As SqlClient.SqlDa taReader = com.ExecuteRead er()

While (dr.Read())
Console.WriteLi ne(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.co mwrote:
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_newsgroup s" <rowe_em...@yah oo.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.DateT ime).Value =
CType(Value, DateTime)
...
Dim numrow As Integer = cmd.ExecuteNonQ uery

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*********@gm ail.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
1725
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. Inputing fractions like (a / b) + (c / d), It's tiring work too. Can it be simplified? 3. How can i input root?
7
1754
by: administrata | last post by:
Is it possible? I tried... I = "John" print \ """ I used to love pizza"""
8
2147
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 option.
7
1547
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" appears) thanks in advance sorry for questions like this...
0
1202
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 automatically so that I don't have to set this sytle every time? 2. I'd like to code have a "New" button, that when selected makes visible a detailview in insert mode and with only the insert command available. I would imagine I'd be adding an...
0
1303
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 automatically so that I don't have to set this sytle every time? 2. I'd like to code have a "New" button, that when selected makes visible a detailview in insert mode and with only the insert command available. I would imagine I'd be adding an...
4
1216
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 23:00:00.000
5
1618
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 tree_list($parent, $level,$id) { // retrieve all children of $parent $result = mysql_query('SELECT cname,cid FROM kategorie '. 'WHERE parent="'.$parent.'";'); while ($row = mysql_fetch_array($result)) {
9
3602
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 "myDB" with a table "myUsers" with fields "Username" and "Password". I also have the MySQL ODBC driver loaded with a DSN "dsnMySQL" setup. First question is can someone direct me to a site or provide a sample code for a login page that...
2
1942
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 very good programmer and OOP is still sinking in, so please don't answer my questions like I really know anything. MY QUESTION: What is a slot? In class Object below the __init__ has a slot. Note: The slot makes use of a data object called...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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 we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.