小编mol*_*anu的帖子

DataReader:指定的强制转换无效(Int32)

为什么在将0转换为整数时SqlDataReader会抛出异常?

?dataReader(3)
0 {Short}
    Short: 0
?dataReader.GetInt16(3)
0
?dataReader.GetInt32(3)
{"Specified cast is not valid."}
    _HResult: -2147467262
    _message: "Specified cast is not valid."
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: Nothing
    HResult: -2147467262
    InnerException: Nothing
    IsTransient: False
    Message: "Specified cast is not valid."
    Source: "System.Data"
    StackTrace: "   at System.Data.SqlClient.SqlBuffer.get_Int32()     
                    at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i)"
    TargetSite: {Int32 get_Int32()}
Run Code Online (Sandbox Code Playgroud)

.net datareader sqldatareader

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

在WPF中画一个十字

我有一个WPF控件.

我需要在背景中有一个十字架,像这样:
在此输入图像描述

在那之后,我将能够在我的"交叉"背景上添加其他控件: 在此输入图像描述

我应该如何绘制十字架,知道当我重新控制控件时,十字架应该遵循它的大小?

.net wpf wpf-controls

6
推荐指数
3
解决办法
6765
查看次数

如何:将匿名方法转换为VB.NET

我在C#中有以下内容:

public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
    double fromValue = (double)animatableElement.GetValue(dependencyProperty);

    DoubleAnimation animation = new DoubleAnimation();
    animation.From = fromValue;
    animation.To = toValue;
    animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);

    //// HERE ----------------------------------------------------
    animation.Completed += delegate(object sender, EventArgs e)
    {
        //
        // When the animation has completed bake final value of the animation
        // into the property.
        //
        animatableElement.SetValue(dependencyProperty,
                                 animatableElement.GetValue(dependencyProperty));
        CancelAnimation(animatableElement, dependencyProperty);

        if (completedEvent != null)
        {
            completedEvent(sender, e);
        }
    };
Run Code Online (Sandbox Code Playgroud)

我有一些问题将匿名方法转换为VB.NET.

我的变体是

  AddHandler animation.Completed,
    Function(sender As …
Run Code Online (Sandbox Code Playgroud)

.net c# vb.net anonymous-function c#-to-vb.net

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

VB.NET代码中的SQL查询

我有一个项目,我们直接在代码中使用SQL查询.

Dim strSQL As String = "SELECT P.NAME, C.ID, C.NAME" +
         "FROM PERSONS P " + 
"INNER JOIN CITIES " +
"ON P.IDCITY = C.ID" +
"WHERE P.ID = {0}"
Run Code Online (Sandbox Code Playgroud)

使用""和"+"格式化这样的查询有点令人讨厌有没有办法编写脚本"按原样"(来自SQL文件),而不重新格式化它?

我用了

strSQL = My.Resources.SELECT_PERSON_WITH_CITY
Run Code Online (Sandbox Code Playgroud)

但在调试中我无法查看/修改原始查询.

我知道,我知道,这不是直接使用SQL的最佳实践,但是,我使用的是我所拥有的.

PS.

正如Conor Gallagher所说,在C#中有一种方法可以达到这个目的:

string x = @"
  my 
  name 
  is {0}";
string y = string.Format(x, "jimmy");
Run Code Online (Sandbox Code Playgroud)

有谁知道VB.NET等价物

.net sql vb.net visual-studio

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