Click here to Skip to main content
15,887,322 members
Home / Discussions / C#
   

C#

 
AnswerRe: Demo Deployment Pin
kasraa0009800014-Jun-10 4:34
kasraa0009800014-Jun-10 4:34 
QuestionClass methods for accessing/modifying multiple array variables Pin
BenBJT14-Jun-10 2:59
BenBJT14-Jun-10 2:59 
AnswerRe: Class methods for accessing/modifying multiple array variables Pin
Łukasz Nowakowski14-Jun-10 3:15
Łukasz Nowakowski14-Jun-10 3:15 
AnswerRe: Class methods for accessing/modifying multiple array variables Pin
Luc Pattyn14-Jun-10 3:26
sitebuilderLuc Pattyn14-Jun-10 3:26 
Questionhow i know when user created Pin
noamtzu0014-Jun-10 2:47
noamtzu0014-Jun-10 2:47 
AnswerRe: how i know when user created Pin
Pete O'Hanlon14-Jun-10 3:36
mvePete O'Hanlon14-Jun-10 3:36 
GeneralRe: how i know when user created Pin
noamtzu0014-Jun-10 18:33
noamtzu0014-Jun-10 18:33 
QuestionGetting a column or parameter's data type from the database [modified] Pin
JohnLBevan14-Jun-10 1:42
professionalJohnLBevan14-Jun-10 1:42 
Hi Folks,

I'm hoping someone can assist me with a (hopefully) simple question. Is there a way to query a database to get the type of the parameters expected by a stored proc, or the column types of a table. I know this can be done through SQL for most databases (e.g. see below, for SQL Server Column Types), but want a solution which works with any database.
SELECT name
from sys.types  
where user_type_id in 
(
	select user_type_id
	from sys.columns 
	WHERE object_id = OBJECT_ID('@schemaName.@tableName')
	and name='@columnName'
)

Background
For anyone wanting to know more about why I'd need this, here's a little more info on what I'm attempting.
I'm writing a web service, which can act as a wrapper to any databases. The databases' connection strings will be included in the config file, using the MS Enterprise Library, so that when a call is made, the name of the DB can be included, which can then be used to get the appropriate connection.
Reading information is pretty simple; given the database name and the table / (parameterless) stored proc name the code reads from that object, and outputs data in the format <tableOrProcName><row><fieldName>...</fieldName>...</row>...</tableOrProcName>.
However, when performing inserts (and other operations where I'd need to be cognizant of data types), I'd like to query the database to get a list of expected parameter/column names and types, which I can then cross reference with the names of the XML 'Field' elements, to convert the values from strings to the correct types before populating the commandText / parameter.

Once coded, I'll make the solution available on here for anyone looking to do the same.

(For anyone wondering why we'd need a wrapper for databases, the answer is many programs these days come with simple methods for attaching to web service calls, but don't provide similar features for databases, so this is a simple & flexible workaround. Security is not an issue, since both the webservice and database are configured to only allow the service account access, so users can't use the service as a backdoor).

Thanks in advance,

JB

modified on Monday, June 14, 2010 7:50 AM

AnswerRe: Getting a column or parameter's data type from the database Pin
PIEBALDconsult14-Jun-10 2:44
mvePIEBALDconsult14-Jun-10 2:44 
GeneralRe: Getting a column or parameter's data type from the database Pin
JohnLBevan14-Jun-10 8:40
professionalJohnLBevan14-Jun-10 8:40 
GeneralRe: Getting a column or parameter's data type from the database Pin
PIEBALDconsult14-Jun-10 13:48
mvePIEBALDconsult14-Jun-10 13:48 
QuestionA few questions Pin
SRJ9214-Jun-10 1:12
SRJ9214-Jun-10 1:12 
AnswerRe: A few questions Pin
Eddy Vluggen14-Jun-10 2:08
professionalEddy Vluggen14-Jun-10 2:08 
GeneralRe: A few questions Pin
SRJ9214-Jun-10 10:08
SRJ9214-Jun-10 10:08 
GeneralRe: A few questions Pin
Eddy Vluggen14-Jun-10 10:38
professionalEddy Vluggen14-Jun-10 10:38 
QuestionLogin dialog on page loads Pin
Ramkithepower14-Jun-10 0:39
Ramkithepower14-Jun-10 0:39 
AnswerWrong forum - Try the ASP.NET forum. Pin
Pete O'Hanlon14-Jun-10 0:42
mvePete O'Hanlon14-Jun-10 0:42 
AnswerRe: Login dialog on page loads Pin
OriginalGriff14-Jun-10 0:43
mveOriginalGriff14-Jun-10 0:43 
AnswerRe: Login dialog on page loads Pin
Ramkithepower14-Jun-10 22:21
Ramkithepower14-Jun-10 22:21 
QuestionScalable Email service Pin
nitin_ion14-Jun-10 0:28
nitin_ion14-Jun-10 0:28 
AnswerRe: Scalable Email service Pin
OriginalGriff14-Jun-10 0:45
mveOriginalGriff14-Jun-10 0:45 
GeneralRe: Scalable Email service Pin
nitin_ion14-Jun-10 1:15
nitin_ion14-Jun-10 1:15 
QuestionFlow control using Asynch Sockets Pin
TimSWatson14-Jun-10 0:14
TimSWatson14-Jun-10 0:14 
AnswerRe: Flow control using Asynch Sockets Pin
Jimmanuel14-Jun-10 3:24
Jimmanuel14-Jun-10 3:24 
GeneralRe: Flow control using Asynch Sockets Pin
TimSWatson14-Jun-10 3:34
TimSWatson14-Jun-10 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.