Local database on windows phone 8 - database

I am a beginner at using windows phone SDK and I am trying to find the best method to create a local database to store app data on a windows phone 8 device. The data is to be stored from one page (not the main page) and retrieved and displayed from another page.
I have tried to use linq to sql and sqlite but as I am a beginner I do not know much about either method.
Can anyone recommend a good tutorial or a method which I can use?
PS: I am using Visual Studio Express 2012 for Windows Phone
Thanks

Here is the code for you to create the database
public class dbDataContext : DataContext
{
// Pass the connection string to the base class.
public dbDataContext(string connectionString)
: base(connectionString)
{ }
// Specify a single table for the idea items.
public Table<className> cn;
}
className is where all your Member variables will be stored with get set method.
then create the database as follows in the file (*.cs) where you want to create the database
private IdeaDataContext yourDb;
yourDb = new dbDataContext("Data Source=isostore:/anyname.sdf");
your database is created

Related

Dapper: Cannot read/map Geometry type field in local SQL Server

I am running ASP.NET Core 2 application.
I have a local instance of SQL Server where I have a table with a column of type Geometry.
When I go to read this table I get the following errors:
Type Udt is not supported on this platform.
Error parsing column 4 (MyLocation)
However this issue only seems to occur in my API project which calls to a custom made Nuget package that handles the CRUD operations.
If I test the same code in the project that does the CRUD it reads and maps my object.
It is not a connection issue in the API for I can successfully read/write other tables that do not have a Geometry field in it.
What could I possible be missing?
Code:
MyController:
public async Task<IActionResult> Get(Guid Id)
{
var rec = await myRepo.Get<MyData>(id);
// then do stuff
}
*myRepo is injected into my controller.
public class MyData
{
public Guid Id {get;set;}
public IGeometry MyLocation {get;set;}
}
myRepo:
public async Task<TEntity> Get<TEntity>(object id)
where TEntity : class
{
_conn.Open();
return await _conn.GetAsync<TEntity>(id);
}
If this is .NET Core, then I suspect you could have significant issues using sqlgeography etc; UDTs essentially aren't yet implemented in .NET Core:
Additionally, the underlying types that you would want to load use native code; the geo/etc types are not, AFAIK, available in .NET Core.
If I'm wrong, I'm more than happy to try to make whatever changes we need to help make this work, but at the time of writing: I don't think this is going to work through any API (it is not specific to Dapper).
You might want to consider using ASP.NET Core on .NET Framework for today? reference .Net framework 4.5.2 from .Net Core 2.0 project
If this data does actually load from ADO.NET in .NET Core, then I'd be happy to fix whatever I've missed.

Azure Mobile Services Starter Issues - Database

I'm trying to create a simple backend for a html/JavaScript app. I started off by creating a new visual Studio Project using the azure mobile Service template. I created a simple DataObject class called 'ProjectItem' which is looking like this:
public class ProjectItem : Microsoft.WindowsAzure.Mobile.Service.EntityData
{
public string Title { get; set; }
public string Description { get; set; }
}
After that I added a table Controller and there was no need to touch any Code in that class.
In the web api config I added this peace of Code:
List<ProjectItem> projectItems = new List<ProjectItem>
{
new ProjectItem {Id = Guid.NewGuid().ToString(), Title = "First Project", Description = "My First Project Description" },
new ProjectItem {Id = Guid.NewGuid().ToString(), Title = "Second Project", Description = "My Second Project Description" }
};
foreach (ProjectItem projectItem in projectItems)
{
context.Set<ProjectItem>().Add(projectItem);
}
I debugged the Service on my localhost and it was working just fine.
Now I wanted to host it on azure and there the Problems started for me.
Here the stepps I did using azure:
I created an empty database on the new Portal
In visual Studio I clicked publish (my solution) and created a new mobile Service selecting the empty database - I didn't touch the rest of the Settings. The mobile Service is now "up and running".
I only have worked with sqlite since now so I opened the database in visual Studio and wanted to look at the test items I created (the 2 Project Items).
But there is no ProjectItem table and no ToDoItem table either!
How can this happen?
What did I do wrong?
Why is it creating the tables running on localhost but when
Publishing on azure it isn't?
I believe that it is not that simple as to create the object model and it will create the same table in the backend (SQL Azure to be clear, or Azure Storage). You need to create it using Azure dashboard, or do the custom API and do as described here. You may do the same in the Visual Studio, i think, or from the SQL Server Management Studio connected to the SQL Azure db.
For Mobile Services, however, if you set the dynamic schema on the dashboard, it will be able to create new columns when they are in the object, but it is not recommended in the production.
So, you did not anything wrong, it looks that the creation of the table programmatically is just not a supported way (only by dashboard or any type of the explorer like SSMS or VS). Anyway (by the way), they will be not in the System Tables branch.

Sonar Api - Access to database

I am writting a widget for Sonar. It has to upload a string and put it in the sonar database. (Table "properties", "prop_key" = "views.def", It change the structure of views for the plugin porfolio manager).
I coded a little form where the user can copy/paste the string. It appears on my sonar web UI. But I don't know what to do now...
I need to put that string into the sonar DB. How can I communicate with the DB from a widget (with API tools) ?
I searched in Sonar API documentation, but I am a bit overflowed by the informations, and it is not everytime clearly explained.
Thanks for the time you will spend on my question.
EDIT : I found how to access to the database table "properties", by the org.sonar.api.config.Settings class. (method setProperty to write, getString to read (a String :p)).
But this methods havn't access to the DB for writting, so the modifications made by setters are not saved :/

How to pass credentials to reportviewer in WPF application SSRS 2008

I am using ReportViewer to show the reports on my windows WPF application using .Net 4.0. These reports are deployed on a separate SSRS 2008 report server and not the local machine. Right now, I am passing the credentials of the server in the following manner:
string userName = configClient.Settings.Get("UserName").Value.ValueXml.InnerText;
string password = configClient.Settings.Get("Password").Value.ValueXml.InnerText;
string domain = configClient.Settings.Get("Domain").Value.ValueXml.InnerText;
IReportServerCredentials irsc = new ReportViewerCredentials(userName, password, domain);
_reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = irsc.NetworkCredentials;
Also, I am using the following settings with the ReportViewer if it is of any use:
_reportViewer.ProcessingMode = ProcessingMode.Remote;
_reportViewer.ShowParameterPrompts = false;
_reportViewer.ServerReport.ReportServerUrl = new Uri(Properties.Settings.Default.ReportServer);
_reportViewer.ServerReport.ReportPath = Properties.Settings.Default.Reports;
I am using the config file to save and retrieve the credentials for the server access, but I do not think this is a secure way of doing it. I would like to implement this in a secure way where I do not need to take the credentials from the user or from the config file. Both the local machine and the server would be on the same network.
I am not sure how to do it, can this be done through impersonation, I am just guessing as I do not have much idea about security and impersonation. Also, if it can be done, can I get a sample or may be a link to an article through which I can get this done.
The core idea is to avoid storing the username and password on the client. I searched for solution but what I got was very vague in nature.
Please do not close this thread as it is an open question, but it is important for me, as I am approaching deadline and working on too many things at a time. Sorry for inconvenience caused if any.
I have found a way to not pass the credentials at all and still be able to retrieve the reports from the Reports Server, but not without help.
I have configured a new Role assignment in the Report Manager using the URL http://localhost/Reports/Pages/Folder.aspx. Go to Properties tab, and add a New Role Assignment and add Everyone and provide the required right to it.
This way, I would not need to pass any credentials from the client for the ReportViewer. Also, it can be used to configure the access for a selected users.

Connect MS access database in JSP pages

I would like to ask you how can I connect a MS access database in JSP pages?Do you know any ready class which I can use?I am using Netbeans to create JSP pages!
Ancient question, but I shall answer anyway. Had to Google around a bit when the same question flummoxed me. Here goes (concise version of stuff found here):
Administratively Register Database
Use MS Access to create a blank database in some directory. (eg. Database1.mdb.) Make sure to close the data base after it is created.
Go to: Control panel -> Admin tool -> ODBC
Under the System DSN tab (for Tomcat version 5 or later – User DSN for earlier
versions), un-highlight any previously selected name and then click on the Add
button.
On the window that then opens up, highlight MS Access Driver & click Finish.
On the ODBC Setup window that then opens, fill in the data source name. This
is the name that you will use to refer to the data base in your Java program – like
arc. This name does not have to match the file name.
.
Then click Select and navigate to the already created database in directory.
Suppose the file name is Database1.mdb. After highlighting the named file,
click OKs all the way back to the original window.
Connect a JSP page to an Access Database
<%# page import="java.sql.*" %>
<%
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=null;
conn = DriverManager.getConnection("jdbc:odbc:arc", "", "");
out.println ("Database Connected.");
%>
Now that the JDBC-ODBC Bridge has been removed from Java 8, the UCanAccess JDBC driver may be a more relevant option for future users. For details, see the related Stack Overflow question
Manipulating an Access database from Java without ODBC

Resources