dataset

Not displaying data in gridview when applying filter to a dataset

有些话、适合烂在心里 提交于 2019-12-20 06:48:52
问题 My gridview is not displaying data when filter protected void Page_Load(object sender, EventArgs e) { OleDbConnection conn=new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Dynacs.accdb"); OleDbDataAdapter da = new OleDbDataAdapter("select empname,pass,status from employees", conn); DataSet ds = new DataSet(); da.Fill(ds, "emp"); GridView1.DataSource = ds.Tables["emp"].Select("status='in'"); GridView1.DataBind(); } 回答1: OleDbDataAdapter da = new OleDbDataAdapter("select

Join multiple DataRows into a single DataRow

眉间皱痕 提交于 2019-12-20 06:17:23
问题 I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object with a single DataTable that uses the following schema: Id : uint AddressA: string AddressB: string Bytes : uint When I run my application, let's say the DataTable gets filled with the following: 1 192.168.0.1 192.168.0.10 300 2 192.168.0.1 192.168.0.20 400 3 192.168.0.1 192.168.0.30 300 4 10.152.0.13 167.10.2.187 80 I'd like to be able to query this DataTable where AddressA is unique and the Bytes column is summed

.NET Window Forms local database

主宰稳场 提交于 2019-12-20 05:23:07
问题 I just started writing a Windows Forms Application and I'd like to store data in a Database but not in an actual DB Server.. something like SQLite (local, server independent). Does .NET have anything like this out of the box? I looked into DataSets but I'm have a hard time populating it. Any pointers are appreciated, thanks! 回答1: You can try SQL Server Compact , i didn't used it, but it seems that it is what you are looking for. 回答2: If you don't have to save a huge amount of data you can use

Converting DataSet into XML with nested elements

北慕城南 提交于 2019-12-20 04:15:30
问题 I am writing a WebService that is supposed to convert DataSet into XML. My DataSet is actually list of hotels with categories. Each hotel can belong to one or more categories. I followed an example from HERE and it works well except I don't get result that I would like. This is what I get: (example 1) <hotels> <hotel> <name>Hilton Resort</name> <category> <catname>Hotel</catname> </category> <category> <catname>Resort</catname> </category> <category> <catname>Golf & Spa</catname> </category>

TableAdapters SQL Injection

坚强是说给别人听的谎言 提交于 2019-12-20 03:44:14
问题 Hi I am using a dataset and in that dataset I have a table adapter. In my table adapters I have used stored procedures as queries. If I use the following lines to insert form data using my table adapter, is it safe against SQL injection? Thanks. UserDataSetTableAdapters.UserInformationTableAdapter myFactory = new TestProject.UserDataSetTableAdapters.UserInformationTableAdapter(); myFactory.spTest_InsertUserInformation(id, frmAddress); 回答1: Without posting your stored-procedure code, there's

How to return table name from stored procedure in dataset

自闭症网瘾萝莉.ら 提交于 2019-12-20 03:43:06
问题 I used a dataset to store 15 tables that I need at the time of loading. When i filled all the tables using stored procedure it returns me all the table but name of the table doesn't comes as that of actual table name in a database. It takes all the table with table name as Table1, Table2, Table3... I want them to be with the name as they actually are in table. SELECT PK_GUEST_TYPE, [DESCRIPTION] FROM L_GUEST_TYPE SELECT PK_AGE_GROUP_ID, AGE_GROUP FROM L_AGE_GROUP SELECT PK_COMPANY_ID, COMPANY

Passing parameter to SQL select statement IN clause acts weird.

不问归期 提交于 2019-12-20 03:32:20
问题 I've got the following query that returns 2 records (in DataSet's query builder) SELECT EmpID, Name, id FROM Users WHERE (CAST(id AS Varchar(20)) IN ('5688','5689')) Now if I do the same query passing the parameter instead from code behind: String param = "'5688','5689'"; it returns null. WHERE (CAST(id AS Varchar(20)) IN (@param)) I tried taking off the very first and last ', but that did not make a diffrence. !!!id is a unique PK!!! Anyone's got a clue? 回答1: The solution I found is quite

Reading SQL to DataSet to XmlDocument

前提是你 提交于 2019-12-20 02:56:09
问题 The code below works dreamy. But can it be made more compact and C#'ish? Especially i have suspicions regarding two issues. Isn't it ugly (old C-style) filling fill a variable by using it as a in-parameter? Can the code be made more compact instead of going through a String ? C# String connectionString = "...", sqlStatement = "select * from Test", output = ""; SqlDataAdapter adapter = new SqlDataAdapter(sqlStatement, connectionString); DataSet dataSet = new DataSet("Contents"); adapter.Fill

Visual Studio 2013 Crashed While add a DataSet in RDLC report

我与影子孤独终老i 提交于 2019-12-20 02:29:08
问题 When I try to add DataSets to any RDLC report within asp.net Project, Visual Studio stop work and restart. 回答1: I have tried adding DataSet using VS 2012 and 2015, both attempts produced an error same as yours. This only happens to one of my VS projects. Took me several hours to find out that the cause is an unused but referenced dll. After removing that from my project references, I can finally add DataSets successfully. 回答2: Apart from reference issue, my case was different. It was 3rd

DataSet does not support System.Nullable<> exception in c#

試著忘記壹切 提交于 2019-12-20 01:46:13
问题 public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { RST_DBDataContext db = new RST_DBDataContext(); var d = (from s in db.TblSpareParts select new { s.SPartName, s.SPartCode, s.ModelID, s.SPartLocation, s.SPartActive, s.SPartSalePrice }).ToArray(); CrystalReport1 c = new CrystalReport1(); c.SetDataSource(d); crystalReportViewer1.ReportSource = c; } } i am trying generate crystal report there in sql table