ado.net

can't add a .accde MS access file(located outside the project folder) as AccessDataSource

本小妞迷上赌 提交于 2019-12-25 17:48:43
问题 I'm pretty sure that the .accde file does exist. I noticed that VS asks for .mdb file, but a .accde is also a MS Access generated database file. Here is the screenshot(hope it helps): 回答1: From the MSDN AccessDataSource page. The AccessDataSource class does not support connecting to Access databases that are protected by a user name or password, because you cannot set the ConnectionString property. If your Access database is protected by a user name or password, use the SqlDataSource control

Change Database-Name/Server at runtime

ε祈祈猫儿з 提交于 2019-12-25 14:47:13
问题 I am using Visual Studios build-in DataSource functions, to work with my application and its database. Now I am facing one little problem; How do I change the database-server in the final project? Obviously the end-users server name will not be the same as mine. Also how can I change it at runtime? My application has functions to find the database-server itself, so it needs to be able to change the database server at runtime (Only at applcations start) . Update 1: Right now I am Changing my

Image from SQL Server Table to asp.net image control

北城余情 提交于 2019-12-25 14:23:27
问题 SqlCommand cmd = new SqlCommand("select top 1(CMTID),COMMENT,HEADING from FTAB ORDER BY CMTID DESC", conn); conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read() == true) { lblHead.Text = sdr["HEADING"].ToString(); lblData.Text = sdr["COMMENT"].ToString(); } conn.Close(); That is the code for normal data value retrieve from table now I want to get picture from SQL Server that is saved as Binary data that code mention in bottom. So I want to retrieve picture into an Image

Normalize a table with a two-column primary key and one other column

一曲冷凌霜 提交于 2019-12-25 12:04:23
问题 My DataTable has 3 columns: A, B and C. None are guaranteed to have unique entries, in non-trivial cases every column will have non-unique entries. The combination of {A, B} is guaranteed to be unique. Because ADO.NET DataTable allows using multiple columns as the primary key, I use A and B as my primary key. A vs B represents a matrix with 0 as the default value, so it's possible for me to guarantee that entries of B will come from a finite pool and for each entry of A, every possible {A, B}

Normalize a table with a two-column primary key and one other column

那年仲夏 提交于 2019-12-25 12:04:20
问题 My DataTable has 3 columns: A, B and C. None are guaranteed to have unique entries, in non-trivial cases every column will have non-unique entries. The combination of {A, B} is guaranteed to be unique. Because ADO.NET DataTable allows using multiple columns as the primary key, I use A and B as my primary key. A vs B represents a matrix with 0 as the default value, so it's possible for me to guarantee that entries of B will come from a finite pool and for each entry of A, every possible {A, B}

How to read a SQL Function Value By SQL Data Reader in C#

狂风中的少年 提交于 2019-12-25 10:08:23
问题 Hi I have a table tblRegistration which have three fields Member_ID(int) Left_Placement(Int) Right_Placement(int) and one function CREATE FUNCTION [dbo].[fnGetChildCount]( @ParentId INT ) RETURNS INT BEGIN DECLARE @ChildCount INT DECLARE @Left INT DECLARE @Right INT SET @ChildCount = 0 IF NOT @ParentId IS NULL AND @ParentId <> 0 BEGIN SET @ChildCount = 1 SELECT @Left = Left_Placement, @Right = Right_Placement FROM tblRegistration WHERE Member_ID = @ParentId SELECT @ChildCount = @ChildCount +

Displaying database and table creation result at the end

邮差的信 提交于 2019-12-25 08:17:06
问题 I am creating database and tables from c# code so at the end i would like to display result like below: TableName Result Table1 Success Table2 Success Table3 Error:Inapproproiate datatype precision for decimal public class Tables { public string Name { get; set; } public List<Column> Columns { get; set; } } public class Column { public string Name { get; set; } public string Datatype { get; set; } public string IsNullable { get; set; } public Int32? Size { get; set; } public byte?

Converting DataTable to list

二次信任 提交于 2019-12-25 07:47:16
问题 public static IList<Task> GetAllTasks() { return _taskSet.Task.ToList<Task>(); // return sampleData.ToList(); } I am converting a dataTable to list and I getting the following error. how can i convert a table to List. Error 1 Instance argument: cannot convert from orkTimeTable.Dataset.TaskSet.TaskDataTable' to 'System.Collections.Generic.IEnumerable<WorkTimeTable.Model.Task>' c:\users\huzaifa.gain\documents\visual studio 2010\Projects\WorkTimeTable\WorkTimeTable\Model\TaskDataService.cs 24 20

How to insert child category by specific parent category into table using ado.net?

谁说胖子不能爱 提交于 2019-12-25 07:34:23
问题 I am trying to insert categories and subcategories from Excel into a database table. I have 1 Excel file which contains some data and from this Excel file I am creating dataset which contains lots of datatables . In this dataset I have 2 datatables in the form of this: Datatable 0 with records: Category ParentCategory Description Electronics jhdkhsd Sports kjshfhs Datatable 1 with records: SubCategory Subcategory ParentCategory Description Mobile Electronics weprwp Tv Electronics sdflskd

load related entities using classic ado.net

守給你的承諾、 提交于 2019-12-25 05:29:05
问题 Environment: WPF + MVVM + Repository Pattern + classic ADO.NET + SQL Background: For simplicity let's consider only 2 tables in database, User and UserType. Tables <i>User</i> : Id, Username, TypeId(fk ref UserType.Id) <i>UserType</i> : Id (pk), TypeName Models public class User { public int Id {get;set;} public string Username {get;set;} public UserType Type {get;set;} } public class UserType { public int Id {get;set;} public string TypeName {get;set;} } Questions: What is best way to load