Monday, 15 February 2010

c# - passing in Geography Type and SQL converts to Geography type? -


How do I get geography data (the lawn / lawn) and it has the geography column in a SQL database. I'm referring Microsoft.SqlServer.Types SqlGeographyBuilder

I should also add that this is SQL2008r2 to get

My C # project too 4.0 is using

This is just a snippet that I am using in my C # code to code:

 < Code> SqlParameter param21 = new SqlParameter (); Param21.ParameterName = "@ Size"; Param21.UdtTypeName = "Geography"; Param21.SqlDbType = System.Data.SqlDbType.Udt; Param21.Size = 1; SqlGeographyBuilder sqlGeogBuild = New SqlGeographyBuilder (); Sql geographical sqlGeog = null; SqlGeogBuild.SetSrid (4267); If (inputReader [parmLatColumnName] length of .ToString () & gt ;. 0 & amp; & amp; inputReader [parmLonColumnName] .ToString () Length & gt ;. 0) {sqlGeogBuild.BeginGeography (OpenGisGeographyType.Point); Sklajogbildkbeginfaigre (Flotkpars (Inputrider [Prmltklumntme] ()) Ktostring, Flotkpars (Inputrider [Prmlonsolumntme] Ktostring ())); SqlGeogBuild.EndFigure (); SqlGeogBuild.EndGeography (); SqlGeog = sqlGeogBuild.Constructed geography; Param21.Value = sqlGeog; } And {param21.Value = DBNull.Value; } SqlComm.Parameters.Add (param21);   

When I used Profiler I found that my query looked like this:

  declared @ p21 sys.geography set @ p21 = convert (sys. geography, 0xE6100000010C00000080B0374040000000806BD057C0) executive insPoints @ stCty = N'31256 ', @ InstrumentType = N' '' 'ogVal', @ FileDate = '2008-01-03 00:00:00', @ EntryNumber = N '' '500' '@ volume = N'NULL, @ p = N'NULL' @ lessor = N 'name' @ lessee = N 'company name' '', @ InstrumentDate = '2000- 01 -12 0:00:00 ', @ duration = 3, @ TermType = n' '' 'year', @ expired = '2010-07-12 00:00:00', @ royalty = 0.00 , 01,00,000, GrossAcres @ = 1.00, 0,00,000, @ AgencyId = N'NULL ', @ Agency = n' Free ', @ EffDate = null, @ survey = N' A500, A06, A700, A400, A900 ' , @ Longitude = -9 1.00,00,00,000, @lititude = 30.00,00,00,000, @ size = @ p21   

why is it a geography Type is to change when I am passing it in a form of geography?

SQL Server permits to define its data type. This is called User Defined Data Type (UDT).

You are using the user-defined type to define @Shape . As you do not have a different user defined data type Georgaphy is defined in your database, this system changes the value for the datatype geography . Episode is not important, it is importtant that using a different property of

SqlParameter class - DbType instead of reference db data type directly to this Will be resolved. However, there is no geography member in it.

It looks like the difference between Net and SQL Server. Try setting up DbType = "Geography" , but it is unlikely to work.

No comments:

Post a Comment