Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Help needed...

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-05-11 : 10:12:47
Hi all

I have a function, in which i am supplying a datatable, and one of its row as arguments

eg: private function Select(byval dt as datatable, byval specification as string)

here specification is the name of the row of dt

-- the function works fine, and result i am getting

Problem is that, i want to use the same fucntion, somewhere elese, where the datatable row has the name "company name" ie, its two word

How can i give in the function like

private function Select(byval testdt as datatable, byval "company name" as string)

I am confused, as i am not able to change the row name also, now(as it affects many parte)

Please someone help me to fix this

Thank you

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-11 : 10:18:45
I have no idea what you are asking ... can you please try re-phrasing your question maybe, or providing an example?

You know that if a function has this definition:

private function Select(dt as datatable, name as string)

you can call it like this:

Select(yourdatatable, "company name")

right ? A string can contain more than 1 word. Is that what you are asking?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-05-11 : 10:26:15
You are correct, i can call the function like that.
What i was asking was when i use the function in another page, i want to define it.
So there i want to change the function signature little bit
First one is private function Select(dt as datatable, name as string)-- works
In the second page, i want to write the definition of function as

private function Select(dt as datatable, "compnay name" as string)
I was asking can i give exactly the same name of the row "Company name" within the argument section of function signature??

I am sorry if i am confusing.
Thanks for your support
Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-11 : 10:27:53
The column name property in a DataColumn in a DataTable can have a space in them. So if you simply pass "company name" in your function, as long as you have a DataColumn in your DataTable with that name, it should be able to find that DataColumn and return the value you need.

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-11 : 10:32:03
I'm sorry, I still have no idea what you are asking. Do you want "company name" to be the DEFAULT value for that argument? If so, then you write it like this:

private function Select(dt as datatable, optional byval name as string = "company name")

also -- If you have a function on one page, and you want to call that function from ANOTHER page, then that means the function does not belong on a page at all. It should be stored in a module or class that both pages can use. One page should never call code from another page (maybe not never, but it is very rare that this would be a good idea).

As always, my simple advice (which people really hate) is this: get a good book on beginning ASP.NET and read it ... or at least skim it. Sounds like you could use a good overview of the basics of asp.net and also vb.net. That's how I learned. .NET is a HUGE difference from vb6 or scripting in SQL or javascript/vbscript -- it is very important to understand object oriented programming concepts.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-05-11 : 10:33:47
Thanks very much for poiting out me
I got it fixed.
Dont know how can i improve my programming ability
Thanks
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-11 : 10:36:07
quote:
Originally posted by reflex2dotnet
Dont know how can i improve my programming ability



Again, simply read a book? Why is this suggestion so crazy to people? try it. You might like it and even maybe ENJOY it! you can read a book on the beach, in bed, on the couch, at the park. it's nice to get away from a computer and brush up on the core concepts. Just try it. even libraries often have good books for FREE that you can read about programming.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-05-11 : 10:43:35
Thank you very much for your sincere advise.
Will try on that!!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 11:00:05
quote:
you can read a book on the beach, in bed, on the couch, at the park...


... on the toilet

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-11 : 11:11:30
Note to self: never borrow a book from Mladen !!!

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 11:17:47
you don't read on the toilet??? weirdo...

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-11 : 11:21:01
I know, we all do it ........ no one is ever supposed to admit it, though !

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 11:22:25
no? how come?

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -