ado.net

How to load varbinary(max) fields only when necessary with ADO.NET Entity Framework?

不打扰是莪最后的温柔 提交于 2020-01-03 08:14:33
问题 I have a varbinary(max) field in one of my tables but I don't need it every time and I'm looking for a way to fetch it from the database only when necessary. I'm using ADO.NET Entity Framework. How to do that? 回答1: The solution was to create a separate table with the varbinary field and make 1-to-1 relationship between the tables 回答2: It is not necessarily to create separate table. You should do several steps. Let's assume that we have table 'Documents' (Id, Name, Data (varbinary)). Open EF

How to load varbinary(max) fields only when necessary with ADO.NET Entity Framework?

老子叫甜甜 提交于 2020-01-03 08:14:09
问题 I have a varbinary(max) field in one of my tables but I don't need it every time and I'm looking for a way to fetch it from the database only when necessary. I'm using ADO.NET Entity Framework. How to do that? 回答1: The solution was to create a separate table with the varbinary field and make 1-to-1 relationship between the tables 回答2: It is not necessarily to create separate table. You should do several steps. Let's assume that we have table 'Documents' (Id, Name, Data (varbinary)). Open EF

Defining DateDiff for a calculated column in a datatable

半世苍凉 提交于 2020-01-03 04:59:24
问题 I have the column DateTimeExpired, and I would like to create another column called "Expired" which will show "Yes" or "No" according to the expiration date - "Yes" if the date has already passed. I wrote this: DataColumn colExpirationDate = new DataColumn("DateTimeExpired", typeof(DateTime)); DataColumn colExpired = new DataColumn("Expired", typeof(string), "IIF(DateDiff(DateTimeExpired, date())>= 0,'No','Yes')"); But I get an exception "The expression contains undefined function call

Filling DataGrid Columns w/ Excel Data in VB

痴心易碎 提交于 2020-01-03 02:57:12
问题 Alright, I finally got this code to work after hours of toiling: Dim path As String = OpenFileDialog1.FileName Dim myDataset As New DataSet() Dim strConn = New OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=" & path & ";Extended Properties=""Excel 12.0;HDR=YES;IMEX=1""") Dim myData As New OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn) myData.Fill(myDataset) DataGridView1.DataSource = myDataset.Tables(0).DefaultView Now that I figured that out I was going to try and

How to parameterize the set for an IN statement using inline SQL? [duplicate]

房东的猫 提交于 2020-01-03 00:52:06
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Parameterizing a SQL IN clause? Hi, I have a query looks like this: SELECT CompanyId FROM CompanyTable WHERE CompanyName IN ('Subway', 'A & W', 'Pizzahut') Is there any way I can use sql parameters for the names list? This is not a stored proc (which I prefer but can't use in this project). When I say 'parameter', I mean parameter in the parametrized inline sql. I use MS Enterprise Library so my parametrized

SQL Scripts from dotnet with transactions

旧时模样 提交于 2020-01-02 12:17:10
问题 I have been trying to execute sql scripts from dotnet (C#) but the sql scripts could contain GO statements and I would like to be able to wrap the collection of scripts in a transaction. I found this question and the accepted answer got me going for handling the GO statements, but if I use a BeginTransaction it throws a InvalidOperationException at the "new ServerConnection" line. SqlConnection connection = new SqlConnection(connectionString); connection.Open(); SqlTransaction transaction =

import from text file to SQL Server Database, is ADO.NET too slow?

早过忘川 提交于 2020-01-02 11:02:56
问题 My program is now still running to import data from a log file into a remote SQL Server Database. The log file is about 80MB in size and contains about 470000 lines, with about 25000 lines of data. My program can import only 300 rows/second, which is really bad. :( public static int ImportData(string strPath) { //NameValueCollection collection = ConfigurationManager.AppSettings; using (TextReader sr = new StreamReader(strPath)) { sr.ReadLine(); //ignore three first lines of log file sr

import from text file to SQL Server Database, is ADO.NET too slow?

…衆ロ難τιáo~ 提交于 2020-01-02 11:02:36
问题 My program is now still running to import data from a log file into a remote SQL Server Database. The log file is about 80MB in size and contains about 470000 lines, with about 25000 lines of data. My program can import only 300 rows/second, which is really bad. :( public static int ImportData(string strPath) { //NameValueCollection collection = ConfigurationManager.AppSettings; using (TextReader sr = new StreamReader(strPath)) { sr.ReadLine(); //ignore three first lines of log file sr

import from text file to SQL Server Database, is ADO.NET too slow?

六月ゝ 毕业季﹏ 提交于 2020-01-02 11:02:21
问题 My program is now still running to import data from a log file into a remote SQL Server Database. The log file is about 80MB in size and contains about 470000 lines, with about 25000 lines of data. My program can import only 300 rows/second, which is really bad. :( public static int ImportData(string strPath) { //NameValueCollection collection = ConfigurationManager.AppSettings; using (TextReader sr = new StreamReader(strPath)) { sr.ReadLine(); //ignore three first lines of log file sr

Utilize ADO.NET within Classic ASP script

左心房为你撑大大i 提交于 2020-01-02 09:57:56
问题 I'm writing some simple queries which return a single value and I'd like to get the ADO.NET ExecuteScalar method's behavior from Classic ASP's ADO libary. However, I'd prefer to not re-invent the wheel. Is it possible to instantiate ADO.NET's Command object within classic ASP? If so, how would I go about doing that? If I do need to re-implement this feature, what is the best way to do that? Here's what I'm trying to do (In VBScript): set cmd = Server.CreateObject("ADODB.Command") cmd