我正在尝试在c#2.0(linqbridge)中使用linq来搜索我的数据库中的患者名称,但是我收到以下错误:System.Data.Datatable不包含AsEnumerable()System.Data的定义.Datatable不包含CopyToDataTable()的定义
我将linqBridge.dll引用添加到我的项目中.我正在使用:
使用System.Linq;
List<string> names = name.Split(' ').ToList();
SqlConnection con = new SqlConnection(m_connection_string);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM PATIENT", con);
DataSet ds = new DataSet();
da.Fill(ds);
var query =
from pat in ds.Tables["PATIENT"].AsEnumerable().Where(c => names.All(val => c.PAT_SEARCH_NAME.Contains(val)))
select pat;
DataTable table = query.CopyToDataTable();
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我已经读过这个版本的LinqBridge(1.1)不包含这个方法..有没有办法解决这个问题?
谢谢.
我正在asp.net中创建一个WebForm,我想用asp中的数据显示gridview:SqlDataSource
当我尝试跳过(传递null)某些参数的值时,我的问题变成了.
这是我的代码的一些片段
在aspx文件中sqldatasource看起来像
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="art_bat_art" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="art_naz" DefaultValue="HLA" ConvertEmptyStringToNull="true" Type="String" />
<asp:Parameter Name="art_sifra" DbType="String" Direction="Input"/>
<asp:Parameter Name="vrsta_id" DefaultValue="3" ConvertEmptyStringToNull="true" Type="Int32" />
<asp:Parameter Name="podvrsta_id" DefaultValue="13" ConvertEmptyStringToNull="true"
Type="Int32" />
<asp:Parameter Name="podgrupa2" DefaultValue="1365" ConvertEmptyStringToNull="true" Type="Int32" />
<asp:Parameter Name="podosobine" DefaultValue="1:9241" ConvertEmptyStringToNull="true"
Type="String" />
<asp:Parameter Name="podosobineOR" DefaultValue="true" ConvertEmptyStringToNull="true"
Type="Boolean" />
</SelectParameters>
Run Code Online (Sandbox Code Playgroud)
我的网格看起来像这样:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1">
Run Code Online (Sandbox Code Playgroud)
代码后面出现问题我的存储过程的一个参数是可选的,如果我在SQL中将它作为null传递,那么无论如何都会执行存储过程.
我试图跳过并传递该参数如下
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void …Run Code Online (Sandbox Code Playgroud) 我正在使用引导程序轮播,它可以很好地使用html中的静态图像列表,但是我希望能够上传新图像并将它们显示在轮播中 - 而无需部署新版本的网站.
这是我用于静态图像列表的html:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1" class=""></li>
<li data-target="#myCarousel" data-slide-to="2" class=""></li>
</ol>
<!-- Images-->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="/Images/Slideshow/Picture1.jpg" alt="First slide">
</div>
<div class="item">
<img src="/Images/Slideshow/Picture2.jpg" alt="Second slide">
</div>
<div class="item">
<img src="/Images/Slideshow/Picture3.jpg" alt="Third slide">
</div>
</div>
<!-- Left Right Arrows -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a> …Run Code Online (Sandbox Code Playgroud) 我有一个ac#website,它允许客户端通过使用第三方ActiveX控件从他们的PC直接连接到远程SQL Server数据库,绕过Web服务器.我最初使用SQLOLEDB提供程序,它工作正常.客户端位于内部网络中(使用Windows计算机和Internet Explorer),并且该网站不适用于普通Internet.
我不得不从使用SQLOLEDB提供程序升级到SQLNCLI10提供程序以满足SQL Server 2008中的新数据类型.它在我的PC上工作,但在生产中中断.我没有意识到它是有效的,因为SQLOLEDB提供程序是Windows操作系统(MDAC/WDAC)的一部分,因此已经存在于客户端的PC上.该SQLNCLI10提供商是作为SQL Server 2008中的一部分,必须要在客户机上分别安装(因为他们大多安装了SQL Server不会有,但我做的).
我可以为他们提供一个链接,以便从中下载独立的Microsoft SQL Server 2008 Native Client提供程序,但是如何检查他们是否已安装它?
为什么我们在构造函数中注入服务作为这样的参数?
import { HeroService } from '../hero.service';
constructor(private heroService: HeroService) { }
Run Code Online (Sandbox Code Playgroud)
与其作为参数传递,不如我们在构造函数中注入:
import { HeroService } from '../hero.service';
constructor() {
this.heroService=HeroService;
}
Run Code Online (Sandbox Code Playgroud)
是否可以按照上述方式进行?
我正在使用jquery对话框弹出一个对话框.
对话框打开时会发生的情况是它按预期显示对话框,但是它会为页面增加额外的高度,并且在大多数屏幕分辨率下,这将导致在浏览器上显示垂直滚动条.显然没有什么可以向下滚动查看,所以非常不希望没有动态滚动条.我试过在整个页面上定位对话框div,但我无法摆脱它.它发生在ie和Firefox中.
这是代码的简化版本:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#divjQueryPopup').dialog({
autoOpen: false,
draggable: true,
width: 500,
open: function (type, data) {
$(this).parent().appendTo('form');
}
});
});
function showDialog(id) {
$('#' + id).dialog('open');
}
function closeDialog(id) {
$('#' + id).dialog('close');
}
</script>
<div style="height: 500px;">
<div style="height:500px;">
<input id="inpTest" type="button" value="Test" onclick="showDialog('divjQueryPopup');" />
</div>
<div id="divjQueryPopup" runat="server">
<div style="padding:10px 20px 10px 20px">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
public City[] Cities { get; set; }
Run Code Online (Sandbox Code Playgroud)
在 City 类中,我有两个属性
public string Name { get; set; }
public string Code { get; set; }
Run Code Online (Sandbox Code Playgroud)
当出现此Cities字段为空的请求时,我想用 Newtonsoft 隐藏它。
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public City[] Cities { get; set; }
Run Code Online (Sandbox Code Playgroud)
但是我试过的这段代码不起作用,因为 Cities它不是空的,而是空的,并且请求在这个数组中总是有两个属性。
在这种情况下我应该如何使用 Newtonsoft?这里需要的对象是否有任何额外的检查?
我正在尝试将下拉列表的值传递给会话变量,然后将此值转换为审阅页面的文本标签.然后需要将此值传递给sql表(不是问题).问题在于每当我尝试调用标签中的下拉列表的值(或索引,我已尝试过两者)时,我都会得到一个null异常.这是我在第一页上的一个下拉列表的代码,以及尝试在下一个页面上创建的会话中绑定它:FirstPage.aspx
<asp:DropDownList ID="ddlInnoc" runat="server">
<asp:ListItem Value="0">No</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)
FirstPage.aspx.cs
Session["Jabs"] = ddlInnoc.SelectedIndex;
Run Code Online (Sandbox Code Playgroud)
SecondPage.aspx
<asp:Label ID="lblJabs" runat="server"></asp:Label>
Run Code Online (Sandbox Code Playgroud)
SecondPage.aspx.cs
lblJabs.Text = Session["Jabs"].ToString();
Run Code Online (Sandbox Code Playgroud)
请有人告诉我,我只是愚蠢!我收到的例外情况如下:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 11: …Run Code Online (Sandbox Code Playgroud) 只需检查\xef\xbc\x8c就不需要找到点了。
\n坐标 z 不= 0。\n堆栈溢出中的老问题都是关于 2d 的。\n提前感谢
我正在使用c#和SQL Server从数据库中获取数据,并在pageload上的页面上填充一些标签.信息来自SQL视图,它在一行中返回一大堆信息.例如:
SELECT 'car' AS product, 12 As daysUntilEOM, '2010-01-01' AS LastHoliday, 23.7 AS Length
返回总是只有一行
我的项目的其余部分正在使用LINQ,我最初开始沿着这条路走下去,但是创建一个我只想一次性使用的对象是什么意思,将所有值作为键值分配给对象配对,然后将它们重新分配给标签文本?似乎有很多毫无意义的编码.
使用datareader似乎也有同样的问题.
我能看到的最简单的解决方案(即最少代码)是使用dataAdapter填充数据集并将数据集从DAL传回页面,然后直接分配给标签.但对于单行数据,这似乎就像使用卡车携带单个番茄一样.
是否有类似ExecuteScalar的东西返回整行而不是第一列?或者,DataAdapter的编码是否足够,我应该不再担心开销?
谢谢!
asp.net ×5
c# ×5
sql-server ×2
3d ×1
angular ×1
asenumerable ×1
carousel ×1
css ×1
datareader ×1
geometry ×1
gridview ×1
html ×1
jquery ×1
jquery-ui ×1
json.net ×1
line-segment ×1
linq ×1
linqbridge ×1
oledb ×1
python ×1
session ×1
sqlncli ×1