Windows phone app

Spikey

Member
Joined
May 2, 2012
Messages
7
Programming Experience
Beginner
hi

I am creating a tourist guide app in Visual Studio for Windows phone, when I started creating the project I didn't really think about whether to use C# or VB, I just created the project in VB, I am using quite a few online tutorials to help me build the app and often the code is in C#, I was therefore wondering if one is better than the other for creating phone apps seeing as most tutorials seem to use C#. The problem is I have already done quite alot of work on the project and don't really want to have to start again. Can anyone advise me on this?

Michael
 
The main reason that most tutorials are in C# is that it was the only language supported by the Windows Phone Developer Tools when they were first released. VB support was added later, so it will be relatively rare to find VB-specific information for WP7 development. Even for .NET development in general there are probably more C# resources available, although the balance is probably greater than for WP7. As Herman says, in terms of development itself there is basically no difference. You just need to decide whether having fewre language-specific resources is a problem. If you know both languages then translating information from C# to VB shouldn't be a big deal. It's generally just a syntax difference.
 
thanks for your replies, I know VB better than C# but I have managed to translate some code, I think I am going to stick with VB as I have already done quite a lot of work developing the application pages, hopefully I can manage translating the more complex code from C# to VB
 
Always have a go at the translations yourself first but, if there's anything you get stuck on, we can always try to help. There are various online converters that can often do a good job but also baulk at more complex stuff. If you're prepared to pay for a tool to convert code then Instant VB from Tangible Software Solutions does as close to a 100% job as I've seen. Note also that there is a link at the top of this page to our Windows Phone-specific site, which may be of benefit.
 
Last edited:
thanks for offering to help, and the advice, I am going to try with some of the translators to see how they work, some of the code I am using is quite complex so I will have to see how I get on, although I am considering making the project again in C# as it could save me alot of time in the long run, it will take me a few hours to replicate the work I have done in VB but it might be the better option
 
I decided to recreate the project in C# as I think this will save alot of time, I have another question though, I am trying to create persistent storage for data about each tour that is created in the application, I tried creating a local database but as far as I can see all the data is lost once the application is closed, I need a way to store the data even when the application (in this case the emulator) is closed, can this be done with a local database?
 
Yes, this can be done with a local database; many applications do it.

I don't believe you stated what type of database. I'm taking a guess that the problem may be with the Copy to Output Directory property of the database. See here for an article: How to: Manage Local Data Files in Your Project

(Notice that the above link is in jmcilhinney's signature named "Why is my data not saved to my database?"; it's a very popular issue.)
 
it is a local database I created using the following code:


public class TourDescription
{
[Column(IsPrimaryKey=true, CanBeNull=false)]
public string TourName
{
get;
set;
}
//[Column(CanBeNull = true)]
public string TourDescriptionText
{
get;
set;
}
//[Column(CanBeNull = true)]
public string TourPhoto
{
get;
set;
}

the problem I am having is that I can write to the database on one page of the application when the button is clicked to move to the next page using the following code:

private void NextButton_Click(object sender, EventArgs e)
{
NavigationService.Navigate(
new Uri("//AddTourDescription.xaml", UriKind.Relative));

using (TourDataContext Tourdb = new TourDataContext(strConnectionString))
{
TourDescription newTourDescription = new TourDescription
{
TourName = tourName.Text,
};
Tourdb.TourDescriptions.InsertOnSubmit(newTourDescription);
Tourdb.SubmitChanges();
MessageBox.Show("Employee Added Successfully!!!");
}
}

but on the next page where I want to write data to a different column of the table I have a problem because I am using the same code format as above, which creates a new instance of the database, I need a way of referring to the same instance of the database that is created in the first page in subsequent pages but i'm not sure how to do this
 
If you are now working on a WP7 application in C# then it's most appropriate that you now post your questions on one of the other sites, preferably the mobile site.

As for the issue, that code doesn't create any database. You would have added the the database to your project in the Solution Explorer. It would presumably have been a Local Database, i.e. a SQL Server CE SDF file. The IDE would then have generated a Data Source and a typed DataSet. It's instances of the DataSet that get created in code. They are just local caches for data from the database. If you populate one DataSet from the database, add new data save it, then populate another DataSet, you will see the data you added. If you close the application, re-open it and then populate a DataSet, you will see the new data again... UNLESS you are running in the debugger and have the database configured to copy on every build.
 
yes sorry I did add the database in the Solution Explorer first, I managed to get it working now, I can save data to the database but when I close the phone emulator and restart it again the data is lost, I really need persistent storage for the data, I understand this should be possible using a local database but i'm not sure how to do it

I am also going to start a new thread in the Windows phone community forums...
 
Back
Top