ado.net

ADO.NET Data Services Entity Framework request error when property setter is internal

◇◆丶佛笑我妖孽 提交于 2019-12-24 00:49:36
问题 I receive an error message when exposing an ADO.NET Data Service using an Entity Framework data model that contains an entity (called "Case") with an internal setter on a property. If I modify the setter to be public (using the entity designer), the data services works fine. I don’t need the entity "Case" exposed in the data service, so I tried to limit which entities are exposed using SetEntitySetAccessRule. This didn’t work, and service end point fails with the same error. public static

Correct C# conversion counterpart for VB's CTYPE()

旧城冷巷雨未停 提交于 2019-12-24 00:49:23
问题 The below is a snippet from VB that I am porting to a C# rewrite. My question is what is receipt_date after the assignment? Is it still an object or is it a string ? Dim receipt_date As Object receipt_date = CType(dr.Item("RECTDT"), String) Would this be the correct C# counterpart? object receipt_date; receipt_date = dr["RECTDT"].ToString(); After both of these execute would the VB version, receipt_date be equal to the C# version? If not, what do I need to do to make it so? Thanks 回答1: Yes,

File uploading and saving to database incorrectly

跟風遠走 提交于 2019-12-23 21:25:02
问题 I'm having a bit of an issue uploading files to a database. The table I'm uploading to has the following structure: dbo.Cover CoverID int PK CoverFileContent varbinary(max) CoverMimeType nvarchar(50) CoverFileName nvarchar(50) FileID int FK I can upload the file using my MVC application without any errors, however in the database the file stores in CoverFileContent as "0x0000000000000000......". All the other information relating to the file, e.g. MimeType, FileName, CoverID, etc uploads

SQLDependency — Invalid SQL

↘锁芯ラ 提交于 2019-12-23 20:15:09
问题 Best I can tell from here, I am not breaking any rules with this query, but the change event fires constantly with an invalid status. SELECT COUNT_BIG([PK_Column]) AS RecordCount FROM [dbo].[My_Table] GROUP BY Varchar_50_Column If I do this, everything works correctly. SELECT [PK_Column] FROM [dbo].[My_Table] However, I don't want to return this much data, and SqlDependency seems to require executing the query once after each time the change event fires to set up (or reset) the subscription.

Filtering DataView with multiple columns

巧了我就是萌 提交于 2019-12-23 20:13:53
问题 In my application I am using a dataview for having the filters to be applied where the filter options are passed dynamically.if there are 2 filter parameters then the dataview should be filtered for parameter1 and then by parameter two. I am using a method which is called in a for loop where I am setting the count to the total no.of parameters selected using a listbox but the filtering is done only for the last parameter. Here is my code: string str = ""; for (int i = 0; i < listbox.Items

Using MiniProfiler for direct ADO.net calls

谁都会走 提交于 2019-12-23 19:05:09
问题 This question will be silly for those who are geeks in C# and profilers. I am new to c# (basically a c++ developer) . I can profile the database queries if it use dbproviderfactory , but i cannot profile the ado.net calls when it is used directly(raw SqlConnection & SqlCommand ). I came across the Miniprofiler code where they also profile direct ADO.net calls. I just dont know how to use it ( integrate it in my profiler ). My code is SqlConnection myConn = new SqlConnection(@"Server=192.168

How Can I Remove Access Db's temporary ldb file

我与影子孤独终老i 提交于 2019-12-23 18:08:42
问题 I have an ASP.NET Project. I am connecting to the DB and then closing and disposing of the connection object. But when anyone enters my site, MS Access creates a temporary dbname.ldb. When I want to download my original mdb file from my server it won't let me access the mdb file. I can't do anything if there is ldb file in server. It's locking mdb file and I can't move it. So what's the problem? I am opening connection and closing it. So why this ldb file not deleting itself after the

ODBC must declare the scalar variable

走远了吗. 提交于 2019-12-23 16:13:59
问题 Consider the code below: string ConnectionString = "dsn=mysql;uid=sa;DATABASE=userdb;"; string qryStr = "insert into info(code) values(@code);"; OdbcConnection con = new OdbcConnection(ConnectionString); OdbcCommand cmd = new OdbcCommand(qryStr,con ); cmd.Parameters.Add("@code", System.Data.Odbc.OdbcType.Int).Value = "999"; cmd.Connection.Open(); OdbcDataReader odbcdtr = cmd.ExecuteReader();//exception "must declare the scalar variable @code" con.Close; This code is raising exception "must

oledb/ado.net: Get the command's text, with all parameters replaced

和自甴很熟 提交于 2019-12-23 14:22:22
问题 Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I finished assigning the parameters. var query = "SELECT * FROM my_table WHERE c1 = ? and c2 = ?"; var cmd = new OleDbCommand(query, connection); cmd.Parameters.Add("@p1", OleDbType.WChar).Value = "hello"; cmd.Parameters.Add("@p2", OleDbType.WChar).Value = "world";

oledb/ado.net: Get the command's text, with all parameters replaced

拈花ヽ惹草 提交于 2019-12-23 14:22:06
问题 Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I finished assigning the parameters. var query = "SELECT * FROM my_table WHERE c1 = ? and c2 = ?"; var cmd = new OleDbCommand(query, connection); cmd.Parameters.Add("@p1", OleDbType.WChar).Value = "hello"; cmd.Parameters.Add("@p2", OleDbType.WChar).Value = "world";