我试图循环遍历gridview的行并检索每行的数据键值,然后执行一些代码来运行sql查询.如何获取变量中每行的数据键值?现在我收到一条错误消息说:
system.web.ui.webcontrols.datakey类型的值不能转换为整数.
这是我的代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For Each row As GridViewRow In GridView1.Rows
Dim therowindex As Integer = row.RowIndex
Dim theid As Integer = GridView1.DataKeys([therowindex])
'execute some more code running queries using the data key value.
Next
End Sub
Run Code Online (Sandbox Code Playgroud) 我有简单的查询,将两个表中的数据加载到GUI中.我正在将加载的数据保存到广泛可用的对象中Clients currentlySelectedClient.
using (var context = new EntityBazaCRM())
{
currentlySelectedClient = context.Kliencis.Include("Podmioty").FirstOrDefault(d => d.KlienciID == klientId);
if (currentlySelectedClient != null)
{
textImie.Text = currentlySelectedClient.Podmioty.PodmiotOsobaImie;
textNazwisko.Text = currentlySelectedClient.Podmioty.PodmiotOsobaNazwisko;
}
else
{
textNazwa.Text = currentlySelectedClient.Podmioty.PodmiotFirmaNazwa;
}
}
Run Code Online (Sandbox Code Playgroud)
所以现在如果我想:
1)保存用户所做的更改我该怎么做?我是否必须在数据库方面准备一些东西?如何处理修改多个表(某些数据在这里,有些数据在那里)?我现在的代码好像写了.KlienciHaslo就好了,但它根本不影响Podmioty.我尝试了不同的组合,但没有运气.
2)将新客户端添加到数据库(并将信息保存到相关表)?
currentClient.Podmioty.PodmiotOsobaImie = textImie.Text; // not saved
currentClient.Podmioty.PodmiotOsobaNazwisko = textNazwisko.Text; // not saved
currentClient.KlienciHaslo = "TEST111"; // saved
using (var context = new EntityBazaCRM())
{
var objectInDB = context.Kliencis.SingleOrDefault(t => t.KlienciID == currentClient.KlienciID);
if (objectInDB != null)
{
// context.ObjectStateManager.ChangeObjectState(currentClient.Podmioty, EntityState.Modified); …Run Code Online (Sandbox Code Playgroud) 在Silverlight中,如何拉伸Line的宽度以填充其中是子元素的StackPanel的宽度?喜欢XAML解决方案,而不是代码隐藏.以下是我在WPF中的表现:
<Line X1="0"
X2="{Binding Path=ActualWidth, ElementName=HolePatternStackPanel}"
Stroke="Gray"
StrokeThickness="1" />
Run Code Online (Sandbox Code Playgroud)
但这在Silverlight中不起作用.
我创建了一个包含按钮的工具栏.
其中3个按钮是剪切复制和粘贴.我设置了每个按钮的命令来剪切复制和粘贴属性,但是当我运行程序时,没有按钮甚至可以点击.他们是残疾人我猜吗?我正在尝试将文本框中的文本框复制并粘贴到tabcontrol中.任何帮助表示赞赏.
<Style TargetType="{x:Type Button}" x:Key="textBoxCommands">
<Setter Property="Content"
Value="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}" />
<Setter Property="CommandTarget"
Value="{Binding ElementName=textBox}" />
</Style>
<Button x:Name="btnCut"
Click="btnCut_Click">
<Image Source="Icons/Cut.png" ToolTip="Cut" />
</Button>
<Button x:Name="btnCopy"
Click="btnCopy_Click"
Command="ApplicationCommands.Copy"
Style="{StaticResource textBoxCommands}">
<Image Source="Icons/Copy.png" ToolTip="Copy" />
</Button>
<Button x:Name="btnPaste"
Click="btnPaste_Click"
Command="ApplicationCommands.Paste"
Style="{StaticResource textBoxCommands}" >
<Image Source="Icons/Paste.png" ToolTip="Paste" />
</Button>
Run Code Online (Sandbox Code Playgroud) 我正在编写一个F#函数,将一个数字分解为素数因子.
let factors primes i =
let mutable j = i
for p in primes do
while (j>1) && (j%p=0) do
j <- j/p
printfn "prime: %i" p
Run Code Online (Sandbox Code Playgroud)
它适用于int值i,但不适用于int64值.该参数primes是一组int值.
我明白为什么会这样 - 类型推断假设函数只接受int参数 - 但我想明确指定参数类型为int64.
是否有可能写这个功能,使得它能向两家合作int和int64?
我有下面的代码,其中我在tblSerials表中搜索的每个序列号并从那里删除它,但问题是,记录可能存在也可能不存在,所以我需要知道记录是否实际被删除,所以我可以使用qty = qty - 1更新另一个具有连续数量的数量的表(如果删除).
SqlConnection conn = new SqlConnection(connString);
for (int i = 0; i <= aSNs.Count()-1; i++)
{
string query = "delete from tblSerials where SerialNumber='" +aSNs[i]+ "'";
SqlCommand cmd = new SqlCommand(query, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
cmd.Dispose();
conn.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,如果有任何方法可以在ExecuteNonQuery()发生后知道某个记录是否已从表中删除.
我们假设删除基础表LINQ-to-SQL将导致抛出异常.
我们假设删除预期的列也会导致它中断 - 它将无法插入或更新该列.但这个假设是否正确?如果我们从不尝试插入或更新该列SELECT,该怎么办 - 该列的数据类型的默认值是否合适?
我们可以对将破坏LINQ-to-SQL的基础表做出哪些更改?我们可以做出哪些改变会忽略它?它是否在运行时验证数据库架构,如果是,何时?
如何删除主键或外键等约束?我们可以添加它们,删除它们,还是在不破坏LINQ-to-SQL的情况下更改它们?
我知道我可以对基础表做的一些事情,我知道一些我不能做的事情.我正在考虑的具体情况是我是否可以在nullable不破坏dbml的情况下向表中添加列.我不记得所以我想在这里记录它.
对于Flex 4.6按钮,可以定义标签和图标:
<s:Button icon="{@Embed('assets/icon.png'}" label="Do the dance" />
Run Code Online (Sandbox Code Playgroud)
corrsesponding皮肤部分是:iconDisplay:BitmapImage并且labelDisplay:IDisplayText由组件(adobe ref)设置.它们在ButtonBase.as中定义
spark.components.supportClasses.ButtonBase
//--------------------------------------------------------------------------
//
// Skin parts
//
//--------------------------------------------------------------------------
[SkinPart(required="false")]
/**
* A skin part that defines an optional icon for the button.
*
* @langversion 3.0
* @playerversion Flash 10.1
* @playerversion AIR 2.0
* @productversion Flex 4.5
*/
public var iconDisplay:BitmapImage;
[SkinPart(required="false")]
/**
* A skin part that defines the label of the button.
*
* @langversion 3.0
* @playerversion Flash 10
* …Run Code Online (Sandbox Code Playgroud) 我EMR 4.0在AWS中创建了一个包含所有可用应用程序的实例Spark.我是通过AWS控制台手动完成的.我启动了集群,并在它启动时连接到主节点.我跑了pyspark.pyspark尝试创建时出现以下错误SparkContext:
2015-09-03 19:36:04,195 ERROR Thread-3 spark.SparkContext(Logging.scala:logError(96)) - - ec2-user,access = WRITE,inode ="/ user":hdfs:hadoop:drwxr- xr-x at
org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkFsPermission(FSPermissionChecker.java:271)
我没有添加任何自定义应用程序,也没有自举,并期望一切正常工作.不知道发生了什么事.任何建议将不胜感激.
Amazon 的 S3 Select允许用户针对 S3 对象编写 SQL,但没有足够的文档说明支持哪些标准 SQL 功能。
根据该文件,亚马逊S3选择支持AVG,COUNT,MAX,MIN,和SUM。但是当我运行任何聚合查询时,我会收到类似的错误
botocore.exceptions.ClientError:调用 SelectObjectContent 操作时发生错误 (UnsupportedSqlOperation):不支持的 SQL 操作 GROUP BY。请查看服务文档以了解支持的操作。
这是一些要重现的代码:
import boto3
client = boto3.client('s3')
response = client.select_object_content(Bucket='my-bucket', Key='object.csv',
ExpressionType='SQL', Expression="select ID, count(*) from s3object group by s.ID ",
InputSerialization = {'CSV':{"FileHeaderInfo": "Use"}, 'CompressionType': 'GZIP'},
OutputSerialization = {'CSV':{}})
event_stream = response['Payload']
with open('output', 'wb') as f:
for event in event_stream:
if 'Records' in event:
data = event['Records']['Payload']
f.write(data)
Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
ado.net ×1
amazon-emr ×1
amazon-s3 ×1
apache-flex ×1
apache-spark ×1
asp.net ×1
boto3 ×1
containers ×1
copy-paste ×1
f# ×1
flex-spark ×1
layout ×1
linq ×1
linq-to-sql ×1
parameters ×1
parent ×1
pyspark ×1
silverlight ×1
skins ×1
sql ×1
sql-server ×1
stretch ×1
types ×1
vb.net ×1
winforms ×1
wpf ×1
xaml ×1