"i get the error that the object [dbo].[name_of_the_doctor] doesn't exist"
Error messages are supposed to give you a small clue as to what you are doing wrong: in this case a very quick read of the error message should tell you what you need to do.
Check your database: look under "Programmability"..."Functions"..."Scalar-values Functions" and check that a function called "name_of_the_doctor" exists.
If it doesn't, then you need to write it...
If it does, try this:
SqlCommand cmd = new SqlCommand("SELECT dbo.name_of_the_doctor(@iddoctor);", conn);
[edit]Markdown strikes again![/edit]