小编Rob*_*ert的帖子

如何在t#中将t-sql的"tinyint"转换为整数?

我tinyint在数据库中有一个列,我希望将其转换Int32为SqlDataReader.

我该怎么做呢?

编辑#1

我最近不得不这样做.

int a = dataReader.GetByte(dr.GetOrdinal("ColumnName"));
Run Code Online (Sandbox Code Playgroud)

#In除了答案

SQL Server数据类型映射

bigint           - GetInt64  
binary           - GetBytes  
int              - GetInt32  
money            - GetDecimal  
rowversion       - GetBytes  
smallint         - GetInt16  
tinyint          - GetByte  
uniqueidentifier - GetGuid   
...
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请访问 - SQL Server数据类型映射

c# sql-server

58
推荐指数
1
解决办法
7万
查看次数

在PowerShell中使用换行符加入数组

我有一系列名称,我正在尝试使用新的行字符加入.我有以下代码

$body = $invalid_hosts -join "`r`n"
$body = "The following files in $Path were found to be invalid and renamed `n`n" + $body
Run Code Online (Sandbox Code Playgroud)

最后,我通过电子邮件发送内容.

$From = "myaddress@domain.com"
$To = "myaddress@domain.com
$subject = "Invalid language files"

Send-MailMessage -SmtpServer "smtp.domain.com" -From $From -To $To -Subject $subject -Body $body
Run Code Online (Sandbox Code Playgroud)

当我收到消息时,该行The following files in <filepath> were found to be invalid and renamed具有预期的双倍空间,但$ invalid_hosts的内容全部在一行上.我也尝试过

$body = $invalid_hosts -join "`n"
Run Code Online (Sandbox Code Playgroud)

和

$body = [string]::join("`n", $invalid_hosts)
Run Code Online (Sandbox Code Playgroud)

这两种方式都没有效果.我需要做些什么来完成这项工作?

powershell join

17
推荐指数
4
解决办法
3万
查看次数

在PHP中打包().非法十六进制数字警告

我在php中使用pack()时遇到了一些问题

$currencypair = "EUR/USD";
$buy_sell = "buy";
$alert_device_token =array("a","a","b");
$message = "Your " . $currencypair . " " . $buy_sell . " alert price has been reached!";
$payload['aps'] = array (
  'alert' => $message,
  'badge' => 1,
  'sound' => 'default'
);
$payload = json_encode($payload);

foreach ($alert_device_token as $alert_device)
{
  $apnsMessage = chr(0) . chr(0) . chr(32) . 
                 pack('H*', str_replace(' ', '', $alert_device)) . 
                 chr(0) . chr(strlen($payload)) . $payload;
  echo $apnsMessage;
}
Run Code Online (Sandbox Code Playgroud)

现在有时我会得到以下警告,运行相同的代码 -

Warning: pack() [function.pack]: Type H: illegal hex …
Run Code Online (Sandbox Code Playgroud)

php hex pack

8
推荐指数
2
解决办法
3万
查看次数

Amazon S3 png 文件没有透明度

我不确定我做错了什么,但上传到 S3 Amazon 存储桶的 PNG 文件显示白色而不是透明,即使本地文件确实显示透明。这是我所拥有的:

$thumb = \PhpThumbFactory::create(
  $content,
  array(
    'jpegQuality' => 100
  ),
  true
);

$thumb->setFormat('PNG');

ob_start();
$thumb->show(true);
$content = ob_get_clean();

//This part is for testing purposes, I store the file locally to see that the transparency is there
$file = 'picture' . '-' . time() . '.png';
file_put_contents($file, $content); //The file created is an image which perfectly shows the transparent, as it should be

//The code below should upload the same file, but somehow it replaces transparency …
Run Code Online (Sandbox Code Playgroud)

php gd zend-framework amazon-s3

5
推荐指数
0
解决办法
1203
查看次数

从javascript里面到drupal模块的路径

有没有办法获得加载.js的drupal(7)模块路径?
我知道JS是一种前端语言,但可能Drupal以某种方式在Drupal对象中传递了这些信息?

基本上我想做这样的事情:

$('#selectable_html').load("selectable_html.html");  
Run Code Online (Sandbox Code Playgroud)

但是,由于Drupal动态构建页面,这个请求转换为"http://___/node/add/selectable_html.html",这显然是错误的.

javascript ajax drupal-7

4
推荐指数
1
解决办法
2161
查看次数

带有 URL 的站点上不存在列表“MyList”

我正在尝试对 SPList 进行查询,但出现错误,指出 List 不存在。如何以正确的方式阅读当前上下文?不知何故是部署问题?

var clientContext = new SP.ClientContext.get_current();;
var oList = clientContext.get_web().get_lists().getByTitle("MyList");

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="SearchUserName" /><Value Type="Text">' + loginName + '</Value></Eq></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, function (sender, args) {
  //do something
}), Function.createDelegate(this, function (sender, args) {
  //log error
}));
Run Code Online (Sandbox Code Playgroud)

我收到错误消息:URL 为“.... 站点路径”的站点上不存在列表“MyList”

我究竟做错了什么?是否有另一种阅读当前上下文的方法?

sharepoint sharepoint-2013

4
推荐指数
1
解决办法
1万
查看次数

解析Web服务响应返回的xml

我已经阅读了很多关于这个主题的问题,但我似乎与我想要做的事情有关.基本上我正在调用一个Web服务来返回有关车辆识别号(VIN)的信息.它返回一个如下所示的xml流:

<VINquery Version="1.0.0" Date="5/25/2003">
  <VIN Number="1HGES15501Lxxxxxx" Status="SUCCESS">
    <Vehicle VINquery_Vehicle_ID="23261" Model_Year="2001" Make="Honda" Model="Civic" Trim_Level="LX Sedan">
      <Item Key="VINquery Vehicle ID" Value="23261" Unit=""/>
      <Item Key="Model Year" Value="2001" Unit=""/>
      <Item Key="Make" Value="Honda" Unit=""/>
      <Item Key="Model" Value="Civic" Unit=""/>
      <Item Key="Trim Level" Value="LX Sedan" Unit=""/>
      <Item Key="Manufactured in" Value="UNITED STATES" Unit=""/>
      <Item Key="Production Seq. Number" Value="xxxxxx" Unit=""/>
      <Item Key="Body Style" Value="SEDAN 4-DR" Unit=""/>
      <Item Key="Engine Type" Value="1.7L L4 SOHC 16V" Unit=""/>
      <Item Key="Transmission-short" Value="5M OD" Unit=""/>
      <Item Key="Transmission-long" Value="5-Speed Manual Overdrive" Unit=""/>
      <Item Key="Driveline" Value="FWD" Unit=""/> …
Run Code Online (Sandbox Code Playgroud)

c# web-services xml-parsing

3
推荐指数
1
解决办法
4万
查看次数

用c#解析邮件正文

我有一个名为email_archive的电子邮件数据库表.该表包含一个名为body的字段和另一个名为raw_headers的字段.我想使用C#(在SharePoint webpart中)在屏幕上显示此表的内容.我一直在尝试找到一个可以解析主体的库,这样我就可以将消息的各个部分返回到窗口.我尝试过Limilabs的一个库,并下载了其他几个库.但是,所有这些似乎都需要一个EML格式的电子邮件.

最新的尝试是尝试使用MailUtilies.

MimeMessage mm = new MimeMessage(header + message);
Run Code Online (Sandbox Code Playgroud)

但这是失败的,因为看起来格式没有通过MimeMessage完整性检查.

有没有人知道使用原始标题和正文内容将电子邮件解析为其组成部分的方法.

标题看起来像这样

MIME-Version: 1.0
Received: from server.domain.com (10.20.205.104) by
 mail.domain.com (xx.xx.xx.xx) with Microsoft SMTP Server id
 8.1.436.0; Mon, 16 Sep 2013 14:33:54 -0700
Received: from server (localhost.localdomain [127.0.0.1])   by
 server.domain.com (8.13.8/8.13.8) with ESMTP id r8GLX4vm007046 for
 <myaddress@domain.com>; Mon, 16 Sep 2013 14:33:04 -0700
From: "service@domain.com" <service@domain.com>
To: My Name <myaddress@domain.com>
Date: Mon, 16 Sep 2013 14:33:04 -0700
Subject: Some Topic
Thread-Topic: Some Topic
Thread-Index: Ac6zJHFgOvb7ZAdeTJC8DzqnAvdnOw==
Message-ID: <153372.442207427-sendEmail@gserver> …
Run Code Online (Sandbox Code Playgroud)

c# parsing mime mime-message

3
推荐指数
1
解决办法
1万
查看次数

使用Egit删除远程分支

我在Eclipse中使用EGit 3.2.我无法弄清楚如何从我的远程存储库中删除分支.我正在研究一个Drupal项目,那里的mod需要我删除master分支.我在服务器上设置了特定于版本的分支(7.x-1.x).当我转到Git透视图并从远程跟踪部分删除主分支时,分支消失但不是从服务器消失.我试过删除然后推回项目无济于事.

我也从PHP的角度尝试了它,转到Team - > Advanced - > Delete Branch并选择master分支.

我需要做什么?

eclipse git egit

3
推荐指数
1
解决办法
1788
查看次数

将两个整数相除以获得 MySQL 中的浮点数

我正在 MySQL 中处理用户定义的函数,该函数采用整数 (mediumint) 并将其除以 100(即 10785 / 100 = 107.85)。提供的整数是一个称为时间的参数。我试过了

DECLARE dtime FLOAT;
SET dtime = time / 100;
DECLARE ftime VARCHAR(10);
Run Code Online (Sandbox Code Playgroud)

这导致了错误,我假设是因为我将两个整数相除并将其分配给一个浮点数

MySQL said: #1064 - You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use near 
'DECLARE ftime VARCHAR(10);
Run Code Online (Sandbox Code Playgroud)

我也试过

SET dtime = CAST(time as FLOAT) / 100.0;
Run Code Online (Sandbox Code Playgroud)

但这会引发错误,因为您似乎无法将数字转换为浮点数。最后,我尝试使用十进制

DECLARE dtime DECIMAL(10,10);
SET dtime = CAST(time AS decimal(10,10)) / CAST(100 as decimal(10,10);
DECLARE …
Run Code Online (Sandbox Code Playgroud)

mysql floating-point user-defined-functions integer-division

3
推荐指数
1
解决办法
6793
查看次数