How to write WPF Entity Framework in Ms Access database - wpf

I am new to WPF. I am unable to write how the code ms access Entity Framework delete code
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AMXCOMPANYDETAILS.AMX_SalesDBDataSet aMX_SalesDBDataSet = ((AMXCOMPANYDETAILS.AMX_SalesDBDataSet)(this.FindResource("aMX_SalesDBDataSet")));
// Load data into the table tblContact. You can modify this code as needed.
AMXCOMPANYDETAILS.AMX_SalesDBDataSetTableAdapters.tblContactTableAdapter aMX_SalesDBDataSettblContactTableAdapter = new AMXCOMPANYDETAILS.AMX_SalesDBDataSetTableAdapters.tblContactTableAdapter();
aMX_SalesDBDataSettblContactTableAdapter.Fill(aMX_SalesDBDataSet.tblContact);
System.Windows.Data.CollectionViewSource tblContactViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tblContactViewSource")));
tblContactViewSource.View.MoveCurrentToFirst();
// Load data into the table tblContactAddress. You can modify this code as needed.
AMXCOMPANYDETAILS.AMX_SalesDBDataSetTableAdapters.tblContactAddressTableAdapter aMX_SalesDBDataSettblContactAddressTableAdapter = new AMXCOMPANYDETAILS.AMX_SalesDBDataSetTableAdapters.tblContactAddressTableAdapter();
AMX_SalesDBDataSettblContactAddressTableAdapter.Fill(aMX_SalesDBDataSet.tblContactAddress);
System.Windows.Data.CollectionViewSource tblContactAddressViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tblContactAddressViewSource")));
tblContactAddressViewSource.View.MoveCurrentToFirst();
}

Related

Entity Framework validating errors

I am trying to add personnel information to an automation with Entity, but when trying to add email information , Validating error evolves. What should i do?
error:
An unhandled exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll
Additional information: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
and my code:
CateringDBEntities sws = new CateringDBEntities();
private void button1_Click(object sender, EventArgs e)
{
Personel sws2 = new Personel();
sws2.p_name = textBox1.Text;
sws2.p_sname = textBox2.Text;
sws2.p_mail = textBox3.Text;
sws.Personel.Add(sws2);
sws.SaveChanges();
MessageBox.Show("Öğrenci Eklendi.");
this.Close();
}

AxInterop.ShockwaveFlashObjects missing in COM objects

I am trying to run SWF game in my WPF application. This game accepts some variables which should be constantly updated (about 100 times a second). I did some research and I know that basically there are 2 possibilities to run SWF in WPF:
Embed WebBrowser and pass path to the SWF file.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// fixes warning about ActiveX security
string C_Drive_local = "file://127.0.0.1/c$/";
// path of the flash file, here its in C:\DemoContent\bounce.swf
Uri swfPath = new Uri( C_Drive_local + "DemoContent/bounce.swf");
// load it in the browser
MySWFBrowser.Source = swfPath;
}
Use WindowsFormsHost to host an AxShockwaveFlash control
private void FlashLoaded(object sender, RoutedEventArgs e)
{
WindowsFormsHost formHost = new WindowsFormsHost();
AxShockwaveFlash axShockwaveFlash = new AxShockwaveFlash();
formHost.Child = axShockwaveFlash;
mainGrid.Children.Add(formHost);
string flashPath = Environment.CurrentDirectory;
flashPath += #"\game.swf";
axShockwaveFlash.Movie = flashPath;
}
I would like to try with AxShockwaveFlash since it provides methods for setting variables but in my COM objects I can not see AxInterop.ShockwaveFlashObjects.dll
I tried to install several different versions of Flash Player but without success. I cannt find any information about it. How can I get AxInterop.ShockwaveFlashObjects.dll ? What should I install to have it?

How can we defer conflict resolution for SQL Express DB as Client & SQL Server as Server using Mycrosoft Sync Framework 2.0

I have a SQL Express DB as local server & SQL Server DB as remote server. I am using SyncOrchestrator sync Agent for Conflict Resolution. whehever there is a conflict, i want to store it, so that later on i get all the conflicts and resolve one by one. But ApplyAction enumeration doesn't have any value like 'SkipChange' or 'Defer'.
Please Guide.
the code is pasted below.
private void btnSync_Click(object sender, RoutedEventArgs e)
{
SqlConnection clientConn = new SqlConnection(connectionstring1);
SqlConnection serverConn = new SqlConnection(connectionstring2);
// create the sync orhcestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
SqlSyncProvider localProvider = new SqlSyncProvider("Scope1", clientConn);
SqlSyncProvider remoteProvider = new SqlSyncProvider("Scope2", serverConn);
// set local provider of orchestrator to a sync provider associated with the
// ProductsScope in the SyncExpressDB express client database
syncOrchestrator.LocalProvider = localProvider;
// set the remote provider of orchestrator to a server sync provider associated with
// the ProductsScope in the SyncDB server database
syncOrchestrator.RemoteProvider = remoteProvider;
// set the direction of sync session to Upload and Download
syncOrchestrator.Direction = SyncDirectionOrder.DownloadAndUpload;
// subscribe for errors that occur when applying changes to the client
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
// execute the synchronization process
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
MessageBox.Show("Synchronization of Table1 Completed");
BindClientTables();
BindServerTables();
}
private void btnServerData_Click(object sender, RoutedEventArgs e)
{
BindServerTables();
}
private void btnClientData_Click(object sender, RoutedEventArgs e)
{
BindClientTables();
}
static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
{
"**Here I want to defer the Resolution for future.**"
}
you should specify RetryNextSync as the action if you want to skip ...
I suggest you don't defer the resolution that long...if you defer it and users continue to update the rows, the rows you have stored when you encountered the conflict would have changed already by the time you loop thru them to resolve the conflicts...

Sharepoint COM works from Silverlight but not from WPF

I'm running into an interesting situation. I need to access a SharePoint site asset library from both a WPF application and an Silverlight application. My Silverlight application is working 100%, but my WPF application gets a (500) Internal Server Error back from the service.
Silverlight Code:
private void Button_Click(object sender, RoutedEventArgs e)
{
ClientContext clientContext = new ClientContext("http://myfullyQualifiedName.com");
clientContext.Load(clientContext.Web);
clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
}
private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
{
}
private void onQueryFailed(object sender, ClientRequestFailedEventArgs args)
{
}
WPF Code:
private void Button_Click(object sender, RoutedEventArgs e)
{
ClientContext clientContext = new ClientContext("http://myfullyqualifiedname.com/");
//clientContext.Credentials = new NetworkCredential("UserName", "Password", "Domain");
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
}
I have tried with and without specifying credentials, either way I get the Internal server error.
Both Silverlight and non Silverlight Sharepoint client DLL's that I use has is version 14.4762.1000.
Now if I change the URL to one of our other sites, the WPF Code works flawlessly. So I think it must be a SharePoint settings somewhere.
Solved !! Why WPF Authentication wouldn't work when Silverlight works. (WPF was trying to use Kerberos, Silverlight was using NTLM) - Simple fix:
ClientContext _clientContext = new ClientContext(sharePointSiteUrl);
Web _web = _clientContext.Web;
_clientContext.Load(_web, website => website.Title);
_clientContext.Load(_web.Webs);
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(sharePointSiteUrl), "NTLM", CredentialCache.DefaultNetworkCredentials);
_clientContext.Credentials = cc;
_clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
_clientContext.ExecuteQuery();
ListCollection _listCollection = _web.Lists;

Silverlight Windows Phone 7: Load Images From URL

I got the code below that is trying to load an image from the web into an Image control, when I run it I get an error on the given line that no network access is allowed:
private void button1_Click(object sender, RoutedEventArgs e)
{
WebClient webClientImgDownloader = new WebClient();
webClientImgDownloader.OpenReadCompleted += new OpenReadCompletedEventHandler(webClientImgDownloader_OpenReadCompleted);
webClientImgDownloader.OpenReadAsync(new Uri("http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/80000/5000/100/85108/85108.strip.print.gif", UriKind.Absolute));
}
void webClientImgDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(e.Result); // ERROR HERE!
image1.Source = bitmap;
}
Silverlight for Windows Phone 7
Trying to download content with WebClient will require a client access policy file to be present on the source server. For images you can avoid this requirement by doing it like this:-
private void button1_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/80000/5000/100/85108/85108.strip.print.gif", UriKind.Absolute)
image1.Source = new BitmapImage(uri);
}
I see you're retrieving the image from Dilbert.com does that site have a cross domain policy file?
Silverlight doesn't support GIF only JPG, so I wrote:
www.lenniedevilliers.net/displaygif.aspx?link=http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/80000/5000/100/85108/85108.strip.print.gif
the displaygif.aspx page convert the GIF into a JPG.
Can you give us the full exception stack trace? the error could be that your phone emulator does not have internet access, or it could be the image on the dilbert server that does not allow anonymous requests that did not originate from their site ... so guidance on a solution will differ :-)

Resources