本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetDouble方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetDouble方法的具体用法?C# SqlDataReader.GetDouble怎么用?C# SqlDataReader.GetDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateDataReader_F
public static double ValidateDataReader_F(SqlDataReader reader,string colname)
{
if(reader.GetValue(reader.GetOrdinal(colname))!=DBNull.Value)
return reader.GetDouble(reader.GetOrdinal(colname));
else
return System.Double.MinValue;
}
示例2: getDBEletric
public string[] getDBEletric()
{
//SELECT TOP 1 [PV_VOLTAGE] FROM [SunCoreDB].[dbo].[PERF_ARRAY] 单元
//SELECT TOP 1 [CAPACITY_CUMULATIVE_EM] FROM [SunCoreDB].[dbo].[PERF_STATION] 阵列
//
String[] eletric = new String[3];
comm.Connection = conn;
comm.Connection.Open();
comm.CommandText = "SELECT TOP 1 [PV_VOLTAGE] FROM [SunCoreDB].[dbo].[PERF_ARRAY]";
dr = comm.ExecuteReader();
dr.Read();
eletric[0] = dr.GetString(0);
dr.Close();
comm.CommandText = "SELECT TOP 1 [CAPACITY_CUMULATIVE_EM] FROM [SunCoreDB].[dbo].[PERF_STATION]";
dr = comm.ExecuteReader();
dr.Read();
eletric[1] = dr.GetDouble(0).ToString();
dr.Close();
eletric[2] = "0";
comm.Connection.Close();
return eletric;
}
示例3: fromSqlDataReader
public static InstitutionBaseInfo fromSqlDataReader(SqlDataReader reader)
{
return new InstitutionBaseInfo
{
Id = reader.GetInt32(0),
Name = reader.GetString(1),
Address = reader.GetString(2),
Lat = reader.GetDouble(3),
Lng = reader.GetDouble(4),
Email = reader.GetString(5),
Phone = reader.GetString(6),
Type = reader.GetInt32(7),
Site = reader.GetString(8),
WorkingHours = reader.GetString(9),
Icon = GetIconUrl(reader.GetInt32(7))
};
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
int id;
if (int.TryParse(Request.QueryString["id"], out id) == false)
{
lblMensagem.Text = "Id inválido !";
return;
}
//SqlConnection conn = new SqlConnection("Server=tcp:eot9dccau4.database.windows.net,1433;Database=testedb;User [email protected];Password=web2015$;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;");
conn.Open();
cmd = new SqlCommand("SELECT Nome, Endereco, Email, Nascimento, Peso FROM tbPessoa WHERE Id = @a", conn);
cmd.Parameters.AddWithValue("@a", id);
reader = cmd.ExecuteReader();
if (reader.Read() == true)
{
TxtNome.Text = reader.GetString(0);
TxtEndereco.Text = reader.GetString(1);
TxtEmail.Text = reader.GetString(2);
TxtNascimento.Text = reader.GetDateTime(3).ToString("dd/MM/yyyy");
TxtPeso.Text = reader.GetDouble(4).ToString("00.0");
}
else
{
lblMensagem.Text = "Id inválido seu burro, usuário anta, aprende a usar isso seu animal!";
}
reader.Close();
reader.Dispose();
cmd.Dispose();
conn.Close();
conn.Dispose();
}
}
示例5: safeGetDouble
protected object safeGetDouble(SqlDataReader reader, string columnName)
{
int ordinal = reader.GetOrdinal(columnName);
return reader.IsDBNull(ordinal) ? null : (object)reader.GetDouble(ordinal);
}
示例6: Satellite
public Satellite(SqlDataReader dr)
{
Id = dr.GetInt32(SatelliteIdField);
Name = dr.GetString(SatelliteNameField);
Altitude = dr.GetDouble(OrbitalAltitudeField);
}
示例7: GetValue
internal object GetValue(SqlDataReader reader, UnitTags unitTypeTag, int i)
{
switch (unitTypeTag)
{
case UnitTags.AllorsString:
return reader.GetString(i);
case UnitTags.AllorsInteger:
return reader.GetInt32(i);
case UnitTags.AllorsFloat:
return reader.GetDouble(i);
case UnitTags.AllorsDecimal:
return reader.GetDecimal(i);
case UnitTags.AllorsBoolean:
return reader.GetBoolean(i);
case UnitTags.AllorsDateTime:
return reader.GetDateTime(i);
case UnitTags.AllorsUnique:
return reader.GetGuid(i);
case UnitTags.AllorsBinary:
return reader.GetValue(i);
default:
throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
}
}
示例8: ToGPSRecords
protected List<GPSRecord> ToGPSRecords(SqlDataReader sqlDataReader)
{
List<GPSRecord> lstRecords = null;
GPSRecord record = new GPSRecord();
while (sqlDataReader.Read())
{
record.MeasureId = sqlDataReader.GetInt32(0);
record.PipeId = sqlDataReader.GetInt32(1);
record.ProjectPointId = sqlDataReader.GetInt32(2);
record.MeasureTime = sqlDataReader.GetDateTime(3);
record.Location = new Point3D(sqlDataReader.GetDouble(4),
sqlDataReader.GetDouble(5),
sqlDataReader.GetDouble(6));
lstRecords.Add(record);
}
return lstRecords;
}
示例9: FillCompatibleITypedSettersFromReader
// Copy multiple fields from reader to ITypedSettersV3
// Assumes caller enforces that reader and setter metadata are compatible
internal static void FillCompatibleITypedSettersFromReader( SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader ) {
for ( int i = 0; i < metaData.Length; i++ ) {
if ( reader.IsDBNull(i) ) {
ValueUtilsSmi.SetDBNull_Unchecked( sink, setters, i );
}
else {
switch ( metaData[i].SqlDbType ) {
case SqlDbType.BigInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int64 ) );
ValueUtilsSmi.SetInt64_Unchecked( sink, setters, i, reader.GetInt64(i) );
break;
case SqlDbType.Binary:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
ValueUtilsSmi.SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.Bit:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Boolean ) );
SetBoolean_Unchecked( sink, setters, i, reader.GetBoolean(i) );
break;
case SqlDbType.Char:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.DateTime:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
break;
case SqlDbType.Decimal:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlDecimal ) );
SetSqlDecimal_Unchecked( sink, setters, i, reader.GetSqlDecimal(i) );
break;
case SqlDbType.Float:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Double ) );
SetDouble_Unchecked( sink, setters, i, reader.GetDouble(i) );
break;
case SqlDbType.Image:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.Int:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int32 ) );
SetInt32_Unchecked( sink, setters, i, reader.GetInt32(i) );
break;
case SqlDbType.Money:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
SetSqlMoney_Unchecked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
break;
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Real:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Single ) );
SetSingle_Unchecked( sink, setters, i, reader.GetFloat(i) );
break;
case SqlDbType.UniqueIdentifier:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Guid ) );
SetGuid_Unchecked( sink, setters, i, reader.GetGuid(i) );
break;
case SqlDbType.SmallDateTime:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
break;
case SqlDbType.SmallInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int16 ) );
SetInt16_Unchecked( sink, setters, i, reader.GetInt16(i) );
break;
case SqlDbType.SmallMoney:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
SetSqlMoney_Checked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
break;
case SqlDbType.Text:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Timestamp:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.TinyInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Byte ) );
SetByte_Unchecked( sink, setters, i, reader.GetByte(i) );
break;
case SqlDbType.VarBinary:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.VarChar:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.String ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Xml:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlXml ) );
SetSqlXml_Unchecked( sink, setters, i, reader.GetSqlXml(i) );
break;
case SqlDbType.Variant:
//.........这里部分代码省略.........
示例10: GetCellValue
private Element GetCellValue(SqlDataReader reader, int col, ElementType type)
{
switch (type) {
case ElementType.LONG:
return new Element(reader.GetInt32(col));
case ElementType.DOUBLE:
return new Element(reader.GetDouble(col));
case ElementType.STRING:
return new Element(reader.GetString(col));
case ElementType.DATETIME:
return new Element(reader.GetDateTime(col));
}
throw new Exception("invalidate data type");
}
示例11: PopulateProduct
public void PopulateProduct(SqlDataReader _dtr, Product obj)
{
int columnIndex = 0;
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_ID);
if (!_dtr.IsDBNull(columnIndex))
{
obj.ID = _dtr.GetInt32((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_NAME);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Name = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_SERIAL);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Serial = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PUBLICPRICE);
if (!_dtr.IsDBNull(columnIndex))
{
obj.PublicPrice = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PRIVATEPRICE);
if (!_dtr.IsDBNull(columnIndex))
{
obj.PrivatePrice = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_CATEGORYID);
if (!_dtr.IsDBNull(columnIndex))
{
obj.CategoryID = _dtr.GetInt32((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PRODUCINGDATE);
if (!_dtr.IsDBNull(columnIndex))
{
obj.ProducingDate = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_EXPIRYDATE);
if (!_dtr.IsDBNull(columnIndex))
{
obj.ExpiryDate = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_VALUE);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Value = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_TAX);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Tax = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PICTURE1);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Picture1 = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PICTURE2);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Picture2 = _dtr.GetString((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_WEIGHT);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Weight = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_HEIGHT);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Height = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_TAX);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Tax = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_DISCOUNT);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Discount = _dtr.GetDouble((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_ISDELETED);
if (!_dtr.IsDBNull(columnIndex))
{
obj.IsDeleted = _dtr.GetBoolean((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_QUANTITY);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Quantity = _dtr.GetInt32((columnIndex));
}
columnIndex = _dtr.GetOrdinal(ProductDataMapper.CN_PRODUCT_PROVIDER);
if (!_dtr.IsDBNull(columnIndex))
{
obj.Provider = _dtr.GetInt32((columnIndex));
}
}
示例12: GetDoubleTest
public void GetDoubleTest ()
{
cmd.CommandText = "select type_double,type_float,convert(float,null)";
cmd.CommandText += " from numeric_family where id=1";
reader = cmd.ExecuteReader ();
reader.Read ();
// Test for standard exceptions
GetMethodTests("Double");
// Test if data is returned correctly
Assert.AreEqual (numericRow["type_double"], reader.GetDouble(0),
"#2 DataValidation Failed");
// Test for standard exceptions
GetMethodTests("SqlDouble");
// Test if data is returned correctly
Assert.AreEqual (numericRow["type_double"], reader.GetSqlDouble(0).Value,
"#4 DataValidation Failed");
reader.Close ();
}
示例13: SqlReadyValue
static string SqlReadyValue(string sqlBuiltString, Column column, int columnIndex, SqlDataReader reader)
{
if (columnIndex > 0)
sqlBuiltString += ", ";
if (reader[columnIndex] == null || String.IsNullOrEmpty(reader[columnIndex].ToString()))
return sqlBuiltString += "NULL";
switch (column.DataType.SqlDataType)
{
case SqlDataType.Int:
sqlBuiltString += reader.GetInt32(columnIndex);
break;
case SqlDataType.SmallInt:
sqlBuiltString += reader.GetInt16(columnIndex);
break;
case SqlDataType.BigInt:
sqlBuiltString += reader.GetInt64(columnIndex);
break;
case SqlDataType.Float:
try
{
float floatNumber = reader.GetFloat(columnIndex);
sqlBuiltString += floatNumber.ToString(CultureInfo.InvariantCulture);
}
catch
{
double doubleNumber = reader.GetDouble(columnIndex);
sqlBuiltString += doubleNumber.ToString(CultureInfo.InvariantCulture);
}
break;
case SqlDataType.Decimal:
decimal decimalNumber = reader.GetDecimal(columnIndex);
sqlBuiltString += decimalNumber.ToString(CultureInfo.InvariantCulture);
break;
case SqlDataType.DateTime2:
case SqlDataType.DateTime:
var date = reader.GetDateTime(columnIndex);
sqlBuiltString += String.Format("TO_DATE('{0}', 'yyyy-mm-dd hh24:mi:ss')", date.ToString("yyyy-MM-dd HH:mm:ss"));
break;
case SqlDataType.Bit:
var bitData = reader.GetBoolean(columnIndex);
sqlBuiltString += bitData == true ? "1" : "0";
break;
case SqlDataType.NVarChar:
case SqlDataType.NVarCharMax:
case SqlDataType.VarChar:
sqlBuiltString += "'" + reader.GetString(columnIndex) + "'";
break;
case SqlDataType.UniqueIdentifier:
sqlBuiltString += "'" + reader.GetGuid(columnIndex).ToString() + "'";
break;
case SqlDataType.VarBinary:
case SqlDataType.VarBinaryMax:
sqlBuiltString += "NULL";
break;
}
return sqlBuiltString;
}
示例14: getDBWeather
public String[] getDBWeather()
{
comm.Connection = conn;
comm.Connection.Open();
comm.CommandText = "SELECT TOP 1 [TEMPRETURE],[HUMIDITY],[WINDSPEED],[WINDDIRECTION],[AIRPRESSURE] FROM [SunCoreDB].[dbo].[PERF_WEATHER2]";
dr = comm.ExecuteReader();
dr.Read();
String []weather=new String[5];
//double tmp = dr.GetDouble(0);
//int a;
weather[0] = dr.GetDouble(0).ToString();
weather[1] = dr.GetDouble(1).ToString();
weather[2] = dr.GetDouble(2).ToString();
weather[3] = dr.GetDouble(3).ToString();
weather[4] = dr.GetDouble(4).ToString();
comm.Connection.Close();
return weather;
}
示例15: ToInclineRecords
protected List<InclineRecord> ToInclineRecords(SqlDataReader sqlDataReader)
{
List<InclineRecord> lstRecords = null;
InclineRecord record = new InclineRecord();
while (sqlDataReader.Read())
{
record.MeasureId = sqlDataReader.GetInt32(0);
record.PipeId = sqlDataReader.GetInt32(1);
record.ProjectPointId = sqlDataReader.GetInt32(2);
record.MeasureTime = sqlDataReader.GetDateTime(3);
record.Alpha = sqlDataReader.GetDouble(4);
record.Beta = sqlDataReader.GetDouble(5);
lstRecords.Add(record);
}
return lstRecords;
}