Results 1 to 2 of 2

Thread: generic sqldb type?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    generic sqldb type?

    Hi there.


    I basically am making a method which will create parameters and what not in order to execute stored procedures in SQL.

    I was wondering, is there a way that I can specify in the parameters.add command, an object which holds the information on the datatype of a field?

    This would save me a lot of time than doing tons of if else statements checking the data type on the field from a table object (which has fields, and its data types).

    So I would have something like:

    Command.Parameters.Add(“@fieldName”, SqlDbType.Int, 4);

    since this method expects a table object, each table object has an array of fields, the array of fields contains information about the fields. (data type, max length, field name etc...)

    The second parameter, I wouldn’t know what field data type it is, but I can get that data type by querying the field object data type attribute, which brings back me the result in a string.



    I hope you understand what I mean…

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    I don't know if this helps but you can do

    new SqlParameter("@fieldname",valueFromSomewhere);

    sample...

    Code:
    SqlCommand1.Parameters.Add(new SqlParameter("@name",this.txtname.Text));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width