ado.net

Binding Picture box

爷,独闯天下 提交于 2019-12-25 02:47:01
问题 I want to know if we can bind a picturebox as this example : Binding b = new Binding("Image", dataset, "Timage.imagee"); pictureBox1.DataBindings.Add(b); 回答1: Try using the Format event of the Binding object: Binding b = new Binding("Image", dataset, "Timage.imagee", true); b.Format += picFormat; pictureBox1.DataBindings.Add(b); private void pic_Format(object sender, ConvertEventArgs e) { Bitmap bmp = null; byte[] img = (byte[])e.Value; using (MemoryStream ms = new MemoryStream()) { ms.Write

Can't update rows in my database using Entity Framework…?

佐手、 提交于 2019-12-25 02:38:20
问题 Okay, this is really weird. I made a simple database with a single table, Customer, which has a single column, Name. From the database I auto-generated an ADO.NET Entity Data Model, and I'm trying to add a new Customer to it like so: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { class Program { static void Main() { Database1Entities db = new Database1Entities(); Customer c = new Customer(); c.Name = "Harry"; db.AddToCustomer(c); db

SqlCommand.ExecuteScalar Cancel

谁说我不能喝 提交于 2019-12-25 02:33:16
问题 Is there any way to run SqlCommand.ExecuteScalar() asynchronously and then cancel it (on the server side as well) whilst it's being executed? 回答1: .NET Framework 4.5 has a ExecuteScalarAsync() method. See here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalarasync(v=vs.110).aspx ExecuteScalarAsync() also has an overload with a CancellationToken parameter that can be used to abandon the operation before the command timeout elapses. 来源: https:/

ADO.NET & Oracle error

大憨熊 提交于 2019-12-25 02:09:16
问题 I am getting an error message in a .NET application. I am very new to using Oracle with .NET. The ADO.NET provider with invariant name 'Oracle.DataAccess.Client' is either not registered in the machine or application config file, or could not be loaded. I have installed devart's oracle driver and also oracle instant client from oracle. But getting this error message. Does anyone know how to solve this? 来源: https://stackoverflow.com/questions/29916234/ado-net-oracle-error

ODBC select statement to get a boolean

穿精又带淫゛_ 提交于 2019-12-25 01:19:16
问题 I'm trying to check whether a Username and Password exist in my MySQL database and if so I need to return true, otherwise false. This is what I have atm: myconn.Open() Dim selectSQL As String = "SELECT * FROM member WHERE Username = " & objMember.Username & " AND Password= " & objMember.Password Dim cmd As New OdbcCommand(selectSQL, myconn) cmd.ExecuteNonQuery() If cmd.Parameters.Count = 1 Then Return True Else Return False End If myconn.Close() myconn.Dispose() All I get is 0, even though

ADO.NET programming says error occured - ExecuteNonQuery requires an open and available connection

亡梦爱人 提交于 2019-12-25 01:19:06
问题 Right now, my professor requires me to implement a case study using ADO.NET to save data into SQL Server. I have already created a database and tables in SQL Server and I'm trying to create some forms in Visual Studio by C# ADO.NET. I write according to a YouTube video. But I don't know why I cannot save my data to database successfully. The result as I write my code like this. Any help would be appreciated. namespace casestudy { public partial class Form2 : Form { SqlConnection vcon2 = new

Why my ADO.NET queries does not run in single execution but they will run in seperate executions?

拟墨画扇 提交于 2019-12-25 01:12:10
问题 Regarding a question and its related answer, I'm trying to create a new table type using SQL queries and run a join query on data which are of this table type. I put both queries in the same script, i.e. create type and select but it is not working. My query is as below (the whole code is brought in the end of question): IF TYPE_ID(N'BranchMappingType') IS NULL CREATE TYPE BranchMappingType As Table (COL_ServerID int, COL_ServerSchema Common._SMALL_, COL_TableName Common._SMALL_, COL_BranchNo

import data from xml into database

送分小仙女□ 提交于 2019-12-25 01:09:39
问题 i would like to import data into my database through an xml file: var doc = XDocument.Load(XMLFile); var nodes = from e in doc.Descendants("Person") where e.Element("PersonID").Value == "1" select e; The person table has same structure as the data from nodes. Is it handy to use entity framework/linq-to-xml ? 回答1: If the XML's format is right - i.e. if it uses the same format that the DataSet uses - you can just read it using DataSet.ReadXml() and then use all of the normal ADO tools for

get data from variable table and return as datatable c#

╄→гoц情女王★ 提交于 2019-12-24 23:16:56
问题 I need to get retrive all of the data from specified tables and I don't need the data to be strongly typed so I am returning it as a data table. public DataTable GetByTypeName(String t) { var type = Type.GetType(t); var dt = new DataTable(); using (var sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["MasterPlanConnectionString"].ConnectionString)) { var sqlComm = new SqlCommand("SELECT * FROM @table", sqlConn); sqlComm.Parameters.AddWithValue("@table", type.Name); sqlConn

Is there a SqlFileStream like class that works with Sql Server 2005?

て烟熏妆下的殇ゞ 提交于 2019-12-24 20:14:25
问题 For the background to this question, see “How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?” that now has a large bounty on it. SqlFileStream gives you an IoStream that sits on top of a blob (varbinary) value that is stored in the database. However due to limitations on SqlFileStream implementation it will only work with Sql Server 2008. Logically I can’t see any reason why the some API cannot be provided on Sql Server 2000 and Sql Server