|
can't see your reply, wait let me get my glasses
|
|
|
|
|
WOULD IT BE MORE APPROPRIATE IF YOU FIRST WROTE A PROGRAM TO TURN CAPS LOCK OFF?
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
See here[^].
Next time, PLEASE post your question in small case normal font so that it is actually readable.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
I have a strongly typed dataset which holds data provided by SQL Server view. When I call the FILL method of the SqlDataAdapter the dataset if populated as expected if the providing SQL Server is running SQL Server 2008.
If the SQL Server is a 2005 edition, I get the following exception :
The conversion of a char data type to a datetime data type resulted in an out-of-range datatime value.
I have executed a SELECT on the SQL View, via SQL Management Studio and data is being returned as expected, I can therefore conclude the problem is when inserting the data into the dataset, but what the actual problem is, I do not know.
Any ideas?
Steve Jowett
-------------------------
Real Programmers don't need comments -- the code is obvious.
|
|
|
|
|
Perhaps you have some Out of range data in a datetime field, sort of '1900-01-01'. Check your data in Management Studio.
|
|
|
|
|
The earliest date is 2006-07-25 00:00:00.000 So I don't believe the problem is with the date columns
Steve Jowett
-------------------------
Real Programmers don't need comments -- the code is obvious.
|
|
|
|
|
If I remember correctly, while I was reading about whats new in sql2008 compared to sql2005, there are 3 or 5 type of character fields type in sql2005 that are not supported any more in sql2008 , I could not find the article. I will post it when I got it.
|
|
|
|
|
I know this will be tedious, but why don't you change your selected statement to return 1 column, test it, then add the next column, test it, and keep adding columns until you get the error.
Just a thought.
|
|
|
|
|
Hi,everyone! I have some controls on a pannel like below:
Standard(ComboBox);
PN(TextBox);
DN(TextBox);
Style(ComboBox)
I want that I could input anyone first as I like (Eh...I mean that I could input "Standard" first or "PN" first),after these four controls are inputed (not NULL),my function which are used to make a jugement whether "PN" value was out of range should be called.
But I don't know how to do ,could you give me some suggestions ?THX a lot!
|
|
|
|
|
You will need to call the Function from the LEAVE event handler of each control. Modify for function to ensure that all the controls contain a valid value and if so perform the necessary calcuations etc.
Steve Jowett
-------------------------
Real Programmers don't need comments -- the code is obvious.
|
|
|
|
|
Hi Every One
I am mostly active on msdn forums, I heard about this site and I said to my self, "Let me test it"
I am building my framework, and I am trying to discover what is possible and what is not. So, here is the current situation :
Dim parameter_in_form as Integer = 0
myfunc(parameter_in_form)
Public Class myclass
Function myfunc(byval parameter_in_function_header)
' get the parameter name
msgbox(get_parameter_name) ' should display "parameter_in_form"
End Function
End Class
Is that possible?
Thanks.
|
|
|
|
|
Nope. You can pass a value (ByVal) or a reference (ByRef, it boils down to the address of a value); a function/method cannot discover how it got what it got or how it used to be called inside the caller.
So
Dim a as int = 123
Dim b as int = 123
myfunc(a)
myfunc(b)
myfunc(123)
all look the same when looking at the parameter from inside myfunc.
And that is all right for almost all situations. A function should react on its input values, they make the "contract". The one time I regret not being able to get the name is to simplify logging, where one would want to write
log(a)
log(b)
to get the output
a = 123
b = 123
but alas that is not possible.
|
|
|
|
|
Hi Luc
Thanks for your explanation.
This sentence of yours get my attention
Luc Pattyn wrote: You can pass a value (ByVal) or a reference (ByRef, it boils down to the address of a value)
So, If I used Byref, (I am guessing here) The parameter inside the function header should have pointer/link to the calling variable, so later on, the parameter declared by "ByRef" will send the value back to the calling variable.
How the parameter knows which variable?
The real requirement for my question is this:
I am creating a generic function that able to update single field in a table, the function look like this
Update(TableName,FieldName,FieldValue,pkName,pkValue)
calling the function is like this
Update("customers","Address","USA","id",4)
that will update the address field in customer table where id = 4.
What I am trying to do is reducing the number of the parameter in this function to be
Update(TableName,FieldValue,pkValue)
and call it by
Dim address as string = "USA"
Dim id as integer = 4
Update("Customers",address,id)
where address is acting as 2 things
1- the field name inside the table as "address"
2- the field value which need to be updated as "USA"
That was my idea, it seem it will not see the light
|
|
|
|
|
Hi again,
I'm not quite sure what you want.
1.
ByRef should be explained well in the documentation and in your VB book. In essence, assuming
Function myfunc(ByRef x as Integer)
x = x + 1
End Function
will increment the variable in the caller, if it really is a variable
Dim a as integer = 12
myfunc(a)
' now a equals 13
myfunc(a+1)
' calculates a local hidden value of 13, which the function then increments, but noone can access any more
2.
what do you mean by "table"? is it an array? a DataTable? or something else entirely.
You might want to show the declaration (and specify the language: VB6 or VB.NET)
Although the conclusion almost certainly will be: can't be done.
|
|
|
|
|
Hi again.
for No 1, as in your example
How "x" knows that it should return it is new value to "a"?
Is there a link between them?
I mean, maybe I can use this link to get what I want?
(I know the answer is NO but I am just clarifying my question)
I hope it is clear
For No 2, I mean Table name inside Sql Server and I am using vb.net . what is vb6? (kidding)
Update(TableName as string,FieldName as string,pkname as string, pkvalue as string)
then I build the sql statement
sql = "UPDATE @tablename SET @fieldname = @fieldvalue WHERE @pkname = @pkvalue"
Then I substitute each @variable with the correct parameter
I got your answer very well, I will search for another crazy idea
|
|
|
|
|
Sam Martini wrote: How "x" knows that it should return it is new value to "a"?
it doesn't. By using the ByRef keyword, what gets passed is not the number 12 but the address of something that holds the value 12. If the calling parameter is a simple variable (or an array element), it would be the address of that variable/element, otherwise (i.e. when it is a constant or an expression) the expression gets evaluated, its value stored in a temporary location (say on stack), and the address of that result gets passed. All that is the compiler's job.
|
|
|
|
|
Very informative and useful.
Thank you for your time.
|
|
|
|
|
you're welcome.
|
|
|
|
|
you want to force the caller of your function to hold the passed value in a special named variable!!!
ok, maybe you find my comment annoying - but it seems you have to learn some basics about "functions", "parameters", "value types" and "reference types". If you do, such questions or "solutions" will never come to your mind, and it's worth the cost in the long term!
Your problem, if I got it right, is solvable by good old: "another level of indirection"...
|
|
|
|
|
Well, First, I don't know in which category I can put your answer, it is annoying as you said, "Yes", but I will not kill my self if that is your purpose :P
Second, I don't know if you read the whole conversation, that what I am asking for can be done in C, and Foxpro, and Python so, knowing the basics of the function or parameter will not help much. If you work in another programming language such Foxpro or Python, I guess it is normal to check if that can be done in vb.net such as these 3 language above.
Third, I know to overcome what I am asking about and that by using old trick being used since vb6 old days which is the collection or hashtable
Dim par1 As New Hashtable
par1.Add("'USA'","address")
myfunc("customer",par1)
Function myfunc(ByVal TableName As String,FieldNameValue As Hashtable)
Dim sql = "SELECT * from " + TableName + " WHERE " + FieldNameValue.Item(key:=FieldNameValue.Keys(0)) + " = " + FieldNameValue.Keys(0)
MsgBox(sql)
End Function
As I said, I am building my framework, asking for some technique if it exist or no, may change the whole idea of my coding in case the answer was "yes"
Forth, this is personal question to you.
Since old days of vb6 and till 2010 of each release, people asking such question, and we got always the same answer "No", ok, but why? because vb is not a scripting language. arrrg, so? why not include such powerful technique in the vb? that will cause Microsoft to lost money regarding it supported in c? why not vb after 4 .net release does not has it? it should be piece of cake for the developer with the existing of that nasty reflection in there hands. That will help a lot of building dynamic Sql statement and building code on the fly and execute it. Security issue? then remove it from c.
my question here not to Microsoft, but to you.
Why you are against it?
|
|
|
|
|
Thank you for your long reply.
I've read the whole conversation, and I'm aware this things can be done in other languages - in C you would do it with the pre-processor... others mentioned it.
So you want't to do this now with .Net, - This lead me to my "not so nice" answer. I just wanted to mention, there a good reasons not to use pre-processors with "textual replacement" any more. If you are planing your framework, you shouldn't force the callers to know which variable names to use, so I said "learn about parameter passing".
@4: This is not so difficult: "Powerful technique" - is the wrong word for "textual replacement" - this is what you wan't. So personally I'm happy with no pre-processing and textual replacement any more. I was a C/C++ programmer long enough to know about the power of macros, but I never missed the nasty debugging (real compile-time type-checking is not possible for the compiler).
Today I would use a "hashtable/dictionary - workarround" you showed, or generate the code on the fly, or use reflection - but the best you can do - check your requirement and think realy hard if you need this. I'm for sure not the smartest person on the planet - but I'm programming for a living for enough years now to "smell" a bad solution. I wanted to do the same thing in the past, but I resisted, and found a better solution. -Again, please don't be angry about my "learn about basics"-statement.
I hope you find a nice solution for your framework and users!
greetings
|
|
|
|
|
johannesnestler wrote: check your requirement and think realy hard if you need this
NO I don't need this
I got your answer very clearly.
I am not an expert in .Net, I moved to it having in mind that it had every thing. I mean by every thing that it has collected all the technique in other languages.
I asked many question in msdn forum, most of them the answer was no.
can that be done:
dim x as myclass
x.Find("customers", <-- after this the intellisinse get list of all fields from sql server so I can list them. The answer was NO
Can I have multiple copy of vs2010 where each one start with it is own setting such as syntax color and loading of extension. the answer was NO
Can I list the local variable inside the function/sub i am currently working in, the answer is NO
These question is not for you or any one to answer, i am just telling you that in my mind I had overdose of expectation about .net, now, I will say ".Net is very powerful, but you should know it is limitation" so that i am asking this kind of question.
I hope you did not get bored with my second long answer, and thank you for you second explanation which I got it 100%
Cheers
|
|
|
|
|
some thoughts:
.NET and it's tooling is a programming environment like many others. If you want to use it's power, you have to use it in the right problem domain. .NET has a huge "problem domain" it can be applied to. You can write Web/Desktop/Mobile/Database-Apps with one Framework. You can use different languages, etc.
You shure don't get "every thing" from it, but i think it's very much compared to other frameworks.
What you have to know is the same for every kind of programming - How you solve your problems with it.
As an example - for all the problems you mentioned there maybe is an solution.
* You can implement your own intellisense behavior, but magic is impossible...
* An VisualStudio-AddIn would do - all IDE settings live in one file (you can export them...) - Shure you need for using AddIn...
* The intellisense lists all local variables you have defined... ? If you use the rigth naming conventions you can tell which are the "global" ones.
What I want to say is: Create some projects, look how others solved common programming problems in .Net - and learn from it. If you are smart in solving problems, you will always find your solution. If you wan't to change the IDE to your needs, do it - if you don't like it- make your own. (easier than it sounds!) - .NET clearly gives you the power.
You will always find limitations in a technology - but .NET is so complete,open and clear - you can bend it to your will!
|
|
|
|
|
Hi again
johannesnestler wrote: * You can implement your own intellisense behavior, but magic is impossible...
That mean, creating my own plug-in VSIX, and use it. And that is not an easy task which I will never do since I can live without it. I prefer wasting my time on something new for my project to the customer that earn me money. I thought such thing can be done in 5 min.
using Enum? Very very very bad idea. so, No answer
johannesnestler wrote: * An VisualStudio-AddIn would do - all IDE settings live in one file (you can export them...)
That work for loading the syntax color and setting the programming language environment, but not for choosing which extension to be loaded where most extensions require to restart VS. Once again I thought that is easy to do by few clicking.
johannesnestler wrote: * The intellisense lists all local variables you have defined... ? If you use the rigth naming conventions you can tell which are the "global" ones
I got the same answer from msdn, that is not an answer more than workaround. Once I get advised not to use naming convention since the .net environment is smart enough to tell where is the error when assigning wrong type to a variable. And now I had to use to solve my simple question which I thought it is (BY DEFAULT) should be there.
I had to change what is in my thoughts
johannesnestler wrote: .NET clearly gives you the power.
I consider the above as an answer to all my questions. .Net gives you the power to any thing, but do it your self.
Nice talking to you
|
|
|
|
|
Sam Martini wrote: So, If I used Byref, (I am guessing here) The parameter inside the function header should have pointer/link to the calling variable
No, the pointer is not to a variable, but to a memory location. At runtime, variable names don't exist.
|
|
|
|
|