Column data type

G

Guest

Hi,

To send the result table from the stored procedure back to a client, I have
to create SqlDataRecord and send the rows one-by-one.

The constructor fro SqlDataRecord needs an instance of the SqlMetaData. To
create this instance I need the type definition for a particular column.

For example:
SqlMetaData data = new SqlMetaData ("ColumnName", SqlDbType.NVarChar, 50);

In my stored procedure I have a data adapter, that fills the data table:
dad.Fill( myTable);

To get column type:
object obj = myTable.Columns[0].DataType.FulName;

This will return System.String.

How can I get the database types for the column, with the length
specification? (SqlDbType.NVarChar, length constrain = 50).

Thanks,
Lubomir
 
G

Guest

Hi Petar,

Thanks

Lubomir



Petar Atanasov said:
Hi, Lubo,
Check this out:

http://msdn2.microsoft.com/en-us/library/ms172137.aspx

HTH,
Petar Atanasov
http://a-wake.net
Hi,

To send the result table from the stored procedure back to a client, I have
to create SqlDataRecord and send the rows one-by-one.

The constructor fro SqlDataRecord needs an instance of the SqlMetaData. To
create this instance I need the type definition for a particular column.

For example:
SqlMetaData data = new SqlMetaData ("ColumnName", SqlDbType.NVarChar, 50);

In my stored procedure I have a data adapter, that fills the data table:
dad.Fill( myTable);

To get column type:
object obj = myTable.Columns[0].DataType.FulName;

This will return System.String.

How can I get the database types for the column, with the length
specification? (SqlDbType.NVarChar, length constrain = 50).

Thanks,
Lubomir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top