|
Access does not support Bulk operations.
You can use a OleDataAdapter to manage saving the changes to the DataTable back to the database, but it's also going to do it one row at a time.
|
|
|
|
|
I want to make program in C# that shows system information of PC.How can I get all this information for PC like: OS version,cpu info,cpu temperature....
https://postimg.org/image/4pyh4xbwl/
https://postimg.org/image/u5t2epylb/
https://postimg.org/image/5dtg7hhen/
https://postimg.org/image/yhho3q5i7/
https://postimg.org/image/cwclg48rj/
https://postimg.org/image/79g8in68v/
https://postimg.org/image/cywh2ycf3/
https://postimg.org/image/jdvhzmj4v/
https://postimg.org/image/hncgy51lr/
https://postimg.org/image/6p17fyd0f/
https://postimg.org/image/5b9kkndr3/
|
|
|
|
|
|
Use WMI to get the information
In your class define following const
const string WMI_SCOPE = "root\\CIMV2";
const string WMI_CLS_Win32_ComputerSystem = "Win32_ComputerSystem";
const string WMI_CLS_Win32_OperatingSystem = "Win32_OperatingSystem";
const string WMI_CLS_Win32_VideoController = "Win32_VideoController";
const string WMI_CLS_Win32_Processor = "Win32_Processor";
try
{
string sQuery = string.Format("SELECT * FROM {0}", WMI_CLS_Win32_OperatingSystem);
ObjectQuery objectQuery = new ObjectQuery(sQuery);
ManagementScope managementScope = new ManagementScope(WMI_SCOPE);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(managementScope, objectQuery);
ManagementOperationObserver results = new ManagementOperationObserver();
results.ObjectReady += new ObjectReadyEventHandler(ManagementObjectResultReady);
results.Completed += new CompletedEventHandler(ManagementObjectResultCompleted);
searcher.Get(results);
}
catch (....)
You will get wmi results in ManagementObjectResultReady event handler. Hope this helps.
|
|
|
|
|
I have a class like so:
public class BaseRef
{
public int id {get; set;}
public string listID {get; set;}
public string Name {get; set;}
}
And have a data column that is of type BaseRef that I added to a DataTable:
this.Columns.Add(new DataColumn("ParentRef", typeof(BaseRef)));
I am using OdbcDataAdapter to get a query, but in this case my query has three separate columns for the id, listID and Name fields of the Parent:
SELECT id, listID, Name FROM ParentTable
I tried to setup a DataAdapterTableMapping and add ColumnMappings, but it doesn't appear that I can map a source column to a property of a class column. I tried:
mapping.ColumnMappings.Add("id", "ParentRef.id");
mapping.ColumnMappings.Add("listID", "ParentRef.listID");
mapping.ColumnMappings.Add("Name", "ParentRef.Name");
Is there a way to get the mapping to map to the properties of my class?
|
|
|
|
|
I don't think that's possible. The DataAdapter wasn't designed to load columns to/from nested classes.
You'd probably have better luck using Dapper[^] instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi All,
I am trying to use Entity Framework Code First, when I am trying to create a table on the already existing database I'm getting the following error: Invalid object name 'etl.PDFBlob'.
Here I am trying to create my Table on the etl schema not on the dbo, I'm not sure what am I missing in this code.
Thanks.
public partial class FileWatcherEntities : DbContext
{
public FileWatcherEntities()
: base(WatcherDB.GetConnectionStringForEnvironment())
{
}
public virtual DbSet<DtsConnection> DtsConnections { get; set; }
public virtual DbSet<DtsVariable> DtsVariables { get; set; }
public virtual DbSet<ErrorLog> ErrorLogs { get; set; }
public virtual DbSet<FileWatcherLog> FileWatcherLogs { get; set; }
public virtual DbSet<ImportedDBDetails_NotUsed> ImportedDBDetails_NotUsed { get; set; }
public virtual DbSet<ImportedSourceDetail> ImportedSourceDetails { get; set; }
public virtual DbSet<PDFBlob> PDFBlobs { get; set; }
public virtual DbSet<PriorityLookup> PriorityLookups { get; set; }
public virtual DbSet<SSIS_Configuration> SSIS_Configurations { get; set; }
public virtual DbSet<ImportMetaData> ImportMetaDatas { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<ErrorLog>()
.Property(e => e.ApplicationName)
.IsUnicode(false);
modelBuilder.Entity<ErrorLog>()
.Property(e => e.Version)
.IsUnicode(false);
modelBuilder.Entity<ErrorLog>()
.Property(e => e.DateTS)
.HasPrecision(2);
modelBuilder.Entity<ErrorLog>()
.Property(e => e.AppUsername)
.IsUnicode(false);
modelBuilder.Entity<PDFBlob>()
.Property(e => e.FileName)
.IsUnicode(false);
var config = modelBuilder.Entity<PDFBlob>().ToTable("PDFBlob", schemaName: "etl");
modelBuilder.Entity<PDFBlob>().HasKey(x => x.Id);
}
}
Here is my Entity Class
[Table("PDFBlob", Schema = "etl")]
public partial class PDFBlob
{
public long Id { get; set; }
[Required]
[StringLength(8000)]
public string FileName { get; set; }
[Required]
public byte[] Content { get; set; }
public long Size { get; set; }
}
And here is how I am trying to access it and its failing at context.SaveChanges method
private static long WritePdfFile(string path)
{
var fInfo = new FileInfo(path);
while (IsFileLocked(fInfo))
Thread.Sleep(500);
var byts = File.ReadAllBytes(path);
using (var context = new FileWatcherEntities())
{
var blb = context.PDFBlobs.Add(new PDFBlob
{
Content = byts,
FileName = Path.GetFileName(path),
Size = byts.Length
});
context.SaveChanges();
return blb.Id;
}
return 0;
}
I have been trying to search online, changing the code and trying to solve in all possible ways, any help is going to be much appreciated.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
indian143 wrote: Invalid object name 'etl.PDFBlob'.
That error means that the EF configuration is working - it's trying to query the table in the etl schema - but either the table doesn't exist, or the user you're connecting as doesn't have permission to access it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am trying Code First approach hence if the table doesn't exist it should create one if table exists it can update the data into it. Can you give me some idea why is it throwing me exception instead of creating a table?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
You said you're using an existing database. In which case, EF will not create or modify the database.
If you want EF to create the database, then you have to let EF create the whole database.
Entity Framework Code First Migrations[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
indian143 wrote: var config = modelBuilder.Entity<PDFBlob>().ToTable("PDFBlob", schemaName: "etl");
I think it should be this...
modelBuilder.Entity<ClassName>().ToTable("TableName", "SchemaName");
|
|
|
|
|
Yeah I tried as you said but still its giving me the following Exception my friend.
Here is the Exception:
An unhandled exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll
I tried in the following way:
modelBuilder.Entity<PDFBlob>().ToTable("PDFBlob", "etl");
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hi,
I am building an application which does work of Active Directory object creation and update. I need to remove mailbox associated with a domain id without deleting the AD object?
Any inputs will be appreciated.
Regards,
Anchal
|
|
|
|
|
Hi,
I am building an application which works on Active Directory user creation and update. How can I create a Linux mail box for an existing AD object (that is an existing domain id)?
|
|
|
|
|
I have an array as such
List<Bitmap> imgList = new List<Bitmap>();
i need to scroll through that list, very quickly and stitch all the images into one. Like so
using (Bitmap b = new Bitmap(imgList[0].Width, imgList[0].Height * imgList.Count, System.Drawing.Imaging.PixelFormat.Format24bppRgb))
{
using (Graphics g = Graphics.FromImage(b))
{
for (int i=0;i<imgList.Count;i++)
{
g.DrawImage(imgList[i], 0, i * imgList[i].Height);
}
}
b.Save(fileName, ImageFormat.Bmp);
Process.Start(f);
}
imgList.Clear()
The problem that i'm running into is that the images are 2000 wide by 2 high, and there could be 30,000-100,000 images in the array. When I try to make a blank bitmap that size, it get a parameter not found error. Any help would be GREATLY appreciated.
|
|
|
|
|
|
Yeah, I'm afraid GDI+, which is the base for the .NET Image processing, was never designed to handle images of that sort of size. I know this from terrible experience, attempting to process mapping images in municipal councils, and back then I was using GDI+ directly from C++, and it was getting itself into a mess when we stated processing files of ~12,000 x 15,000 pixels.
You are probably going to need to look at doing something in C++, using a library like ImageMagik or similar, to process these images.
One possbility in C#, if you don't want to load the final image, is to look up the internal structure of a BMP file. You could then write the headers and the raw data from the smaller files directly to that file. I really don't fancy your chances of loading it in .NET again afterwards, though.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
You should explain "why" you want / need to do this.
The concept of "virtualization" could be applied here if it's simply a case of making something "look" like it was all "stitched together".
(Cannot think of any "practical" purpose otherwise).
|
|
|
|
|
You do not need to stitch them into a single bitmap to give the user the impression it is a single picture.
Draw on a Panel or something. When the user drags it, update your virtual coordinates and calculate which parts of which bitmap to draw onto the canvas.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You physically can't create a bitmap that size. As you're, presumably, wanting to appear as though the image is stitched when scrolling, you need to actually allocate a bitmap area that is about twice the size of the visible viewport (this is roughly how things like Google maps handles their images). As you scroll around, you will display the area that you have preloaded - when you get near the edge of the viewport, discard a load of these bitmap images from the opposite (invisible) side of the viewport and load in more on the side you can see. If you think of them as tiles, you should get the idea of how to do this.
This space for rent
|
|
|
|
|
Thanks for all the feedback. As far as virtualization or blocked segments go, that doesn't work because i need the image to be archived for later use (after it's stitched of course). The best solution I've found so far is the create several small stitched images. ¯\_(ツ)_/¯
Perhaps, assuming i don't find a .net solution, I'll circle back when i have more time and take a stab at it in c++.
|
|
|
|
|
I'd recommend first calculating whether such a bitmap is feasible. And no, current description still does not show a 'need' for stitching.
What is the use-case for having such a large bitmap archived?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
JBHowl wrote: I'll circle back when i have more time and take a stab at it in c++.
If and when you do, seriously take a look att the open-source ImageMagick: Application Program Interfaces[^]. It is not overly difficult to use, and for large images such as you're describing, it implements its own disk-caching system. Its been around since Noah was a lad, so its relatively stable.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
Hi,
If you have a number of .bmp files, it isn't hard to create a stack of them in a new .bmp file without even using the Image or Bitmap classes, provided all images have equal width.
All it takes is some understanding of the BMP file format[^] (basically locate the height information, and the border between header and pixel data), creating the BMP header, and stitching the data half of each of the .bmp files together.
The input images don't even have to be files, you could apply the same to memory streams. So what I would suggest is this: open an output stream, emit the BMP header for the resulting image (could be based on an input image with the height adapted appropriately), then enumerate the images, and for each of them create the memory stream, then append the byte data skipping the input header.
However, I do agree with the others, my first approach would be to avoid the need for a huge image altogether, as working with huge images will cause heavy memory loads, big latency times, and/or fatal errors. When huge amounts of data are involved, streaming is the way to go; stitching things together statically goes the wrong way. If part of your system needs the whole data, then try and fix that if at all possible.
PS & FWIW: I guess it is easy to show your image using a ListBox where each item corresponds to one input image; make it user drawn so no time is wasted in loading and painting items that aren't currently visible.
modified 21-Oct-16 20:06pm.
|
|
|
|
|
hi guys,
I have developed a MVC implementation 5, it works perfectly locally
but I published it on IIS and I have had this problem
//
in the controller I
public ActionResult Index ()
{
CatalogModel m = new CatalogModel ();
m.LocalCodeColumn = 1;
m.PriceColumn = 2;
m.SelectedClientList = m.GetClientSelectedItems ();
return View (m);
}
and in the view:
Select Client: @ Html.DropDownListFor (m => m.SelectedClientList, Model.GetClientSelectedItems (), "--Select--", new {@id = "ddlClient"})
and this function :
public IEnumerable<SelectListItem> GetClientSelectedItems()
{
IEnumerable<SelectListItem> listClient = dataServices.GetClients();
return listClient;
}
i dont know if the problem with the framework on the server or else
Thank you
modified 20-Oct-16 11:12am.
|
|
|
|