UPDATE myTable
SET theBlobField =
(SELECT BulkColumn FROM OPENROWSET (BULK 'C:\logo.png, SINGLE_BLOB) a)
WHERE [ID] = 1
Friday, May 31, 2013
How to save binary (BLOB) field into local file from SQL Server database by SQL?
DECLARE @SQLIMG VARCHAR(MAX), @IMG_PATH VARBINARY(MAX), @TIMESTAMP VARCHAR(MAX), @ObjectToken INT DECLARE IMGPATH CURSOR FAST_FORWARD FOR SELECT csl_CompanyLogo from mlm_CSCompanySettingsLocalizations OPEN IMGPATH FETCH NEXT FROM IMGPATH INTO @IMG_PATH WHILE @@FETCH_STATUS = 0 BEGIN SET @TIMESTAMP = 'd:\' + replace(replace(replace(replace(convert(varchar,getdate(),121),'-',''),':',''),'.',''),' ','') + '.bmp' PRINT @TIMESTAMP PRINT @SQLIMG EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT EXEC sp_OASetProperty @ObjectToken, 'Type', 1 EXEC sp_OAMethod @ObjectToken, 'Open' EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @IMG_PATH EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @TIMESTAMP, 2 EXEC sp_OAMethod @ObjectToken, 'Close' EXEC sp_OADestroy @ObjectToken FETCH NEXT FROM IMGPATH INTO @IMG_PATH END CLOSE IMGPATH DEALLOCATE IMGPATH
Reference:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=101754
Thursday, May 30, 2013
How to solve "null reference exception" problem when turn off ProxyCreationEnabled in Code first Entity framework?
If turn on lazy loading in entity framework by:
Configuration.ProxyCreationEnabled = false;
Will get null reference exception problem when try to get navigation properties.
Need to do eagerly loading for navigation property by include clause
Configuration.ProxyCreationEnabled = false;
Will get null reference exception problem when try to get navigation properties.
Need to do eagerly loading for navigation property by include clause
using (var context = new BloggingContext())
{
// Load all blogs and related posts
var blogs1 = context.Blogs
.Include(b => b.Posts)
.ToList();
}
Inheritance in Entity Framework Code First
public abstract class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}
public class StaffMember : Person
{
public string BadgeNumber { get; set; }
[ForeignKey("StaffMemberID")]
public virtual ICollection Appointments { get; set; }
}
public class Client : Person
{
[ForeignKey("ClientID")]
public virtual ICollection Appointments { get; set; }
}
public class MyContext : DbContext
{
public DbSet People { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
public void Seed(MyContext context)
{
Client c1 = new Client { Name = "Steve Client" };
StaffMember sm1 = new StaffMember { Name = "Staff 1", BadgeNumber = "1234" };
StaffMember sm2 = new StaffMember { Name = "Staff 2", BadgeNumber = "5678" };
context.People.Add(c1);
context.People.Add(sm1);
context.SaveChanges();
}
public MyContext()
{
Database.SetInitializer(new DropCreateDatabaseAlways());
this.Seed(this);
}
}
http://sgordondeveloper.blogspot.ca/2013/02/model-inheritance-with-relationship-in.html
Friday, May 24, 2013
What's the difference between IFrame and Frameset?
Frameset is dead and long live iframe :)
Frameset replace body elment. And ifeame can be anywhere in the body. Also frameset is NOT supported in HTML 5
http://www.w3.org/TR/html401/frameset.dtd
Frameset replace body elment. And ifeame can be anywhere in the body. Also frameset is NOT supported in HTML 5
http://www.w3.org/TR/html401/frameset.dtd
Subscribe to:
Posts (Atom)