Click here to Skip to main content
15,889,335 members
Home / Discussions / C#
   

C#

 
QuestionRe: i am binding counrty dropdownlist from database data in that i want to display india first is it possible with use of sql query Pin
thatraja20-Nov-13 1:35
professionalthatraja20-Nov-13 1:35 
AnswerRe: i am binding counrty dropdownlist from database data in that i want to display india first is it possible with use of sql query Pin
thatraja20-Nov-13 1:51
professionalthatraja20-Nov-13 1:51 
Question[Solved] SqlCeException (0x80004005) Pin
emma.sun.sts19-Nov-13 23:33
emma.sun.sts19-Nov-13 23:33 
AnswerRe: SqlCeException (0x80004005) PinPopular
OriginalGriff20-Nov-13 5:34
mveOriginalGriff20-Nov-13 5:34 
GeneralRe: SqlCeException (0x80004005) Pin
emma.sun.sts20-Nov-13 9:36
emma.sun.sts20-Nov-13 9:36 
GeneralRe: SqlCeException (0x80004005) Pin
Pete O'Hanlon20-Nov-13 9:48
mvePete O'Hanlon20-Nov-13 9:48 
GeneralRe: SqlCeException (0x80004005) Pin
emma.sun.sts20-Nov-13 10:01
emma.sun.sts20-Nov-13 10:01 
QuestionSQL database compatibility issue and database data reset Pin
emma.sun.sts19-Nov-13 20:34
emma.sun.sts19-Nov-13 20:34 
Hi,

Even when I create sql database with the latest version, there is still this compatibility error, and so I added UpgradeDatabasewithCaseSensitive() as mentioned in http://msdn.microsoft.com/en-us/library/bb896160(v=vs.100).aspx in my form.

After I debug and compile my program for the first time, the program runs fine subsequently without UpgradeDatabasewithCaseSensitive() anymore. But after some undefined time, when I debug and compile again, the compatibility error appears again and all the data I have saved so far in my database is all gone.

I decided to switch on and off visual studio window and run the program again. Sometimes, I can run the program without needing UpgradeDatabasewithCaseSensitive(). Sometimes, I need to include it. I decided to switch on and off my laptop and run the program again. The problem still remains. The program runs sometimes without needing to upgrade and sometimes needs to upgrade (then all the data is gone).

Why doesn't the data remain in database? Can someone help please? I'm still a novice with c#. Below is my code.

STS

//code
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da;
DataSet ds1;

private void connectSQLserver()
{
//Connecting to SQL Server Express Database
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = @"Data Source=C:\Visual Studio 2010\Projects\Form\Form\bin\Debug\database.sdf";
UpgradeDatabasewithCaseSensitive(); //update only once first time
try
{
con.Open();
}
catch (Exception e)
{
MessageBox.Show("Error : " + e.ToString());
}
ds1 = new DataSet();
string sql = "SELECT * From upnp_daily_energy";
da = new System.Data.SqlServerCe.SqlCeDataAdapter(sql, con);

try //run the query
{
da.Fill(ds1, "upnp_daily"); //run the query
}
catch (Exception e2)
{
MessageBox.Show("Error : " + e2.ToString());
}
MessageBox.Show("Connection Open"); //<<---DEBUG
}

public static void UpgradeDatabasewithCaseSensitive()
{
// Default case-insentive connection string.
// Note that .sdf is an old 3.1 version database.

string connStringCI = "Data Source= upnp_database.sdf; LCID= 1033";

// Set "Case Sensitive" to true to change the collation from CI to CS.
string connStringCS = "Data Source= upnp_database.sdf; LCID= 1033; Case Sensitive=true";

SqlCeEngine engine = new SqlCeEngine(connStringCI);

// The collation of the database will be case sensitive because of
// the new connection string used by the Upgrade method.

try
{
engine.Upgrade(connStringCS);
}
catch (Exception ex3)
{
MessageBox.Show("Error 2: " + ex3.ToString());
}

SqlCeConnection conn = null;
conn = new SqlCeConnection(connStringCI);
conn.Open();

//Retrieve the connection string information - notice the 'Case Sensitive' value.
List<keyvaluepair<string, string="">> dbinfo = conn.GetDatabaseInfo();

Console.WriteLine("\nGetDatabaseInfo() results:");

foreach (KeyValuePair<string, string=""> kvp in dbinfo)
{
Console.WriteLine(kvp);
}
}

modified 20-Nov-13 2:42am.

QuestionSkydrive File Upload Pin
mdsajidfaizan19-Nov-13 20:08
professionalmdsajidfaizan19-Nov-13 20:08 
AnswerRe: Skydrive File Upload Pin
Abhinav S19-Nov-13 21:26
Abhinav S19-Nov-13 21:26 
QuestionRead email attachments using C# Pin
surenred19-Nov-13 18:15
surenred19-Nov-13 18:15 
AnswerRe: Read email attachments using C# Pin
Richard MacCutchan19-Nov-13 21:51
mveRichard MacCutchan19-Nov-13 21:51 
AnswerRe: Read email attachments using C# Pin
BillWoodruff20-Nov-13 6:58
professionalBillWoodruff20-Nov-13 6:58 
QuestionUnable to write frame to the video writer Pin
mharicz19-Nov-13 17:41
mharicz19-Nov-13 17:41 
AnswerRe: Unable to write frame to the video writer Pin
Richard Andrew x6419-Nov-13 17:45
professionalRichard Andrew x6419-Nov-13 17:45 
QuestionHow to create Sublime Text like Command Palette in DotNet C# Desktop Application Pin
Sanket S Sonavane19-Nov-13 14:45
Sanket S Sonavane19-Nov-13 14:45 
AnswerRe: Create Sublime Text like Command Palette in DotNet C# Desktop Application Pin
Mycroft Holmes19-Nov-13 15:25
professionalMycroft Holmes19-Nov-13 15:25 
GeneralRe: Create Sublime Text like Command Palette in DotNet C# Desktop Application Pin
Sanket S Sonavane19-Nov-13 16:00
Sanket S Sonavane19-Nov-13 16:00 
AnswerRe: How to create Sublime Text like Command Palette in DotNet C# Desktop Application Pin
BillWoodruff19-Nov-13 19:01
professionalBillWoodruff19-Nov-13 19:01 
GeneralRe: How to create Sublime Text like Command Palette in DotNet C# Desktop Application Pin
Sanket S Sonavane19-Nov-13 20:36
Sanket S Sonavane19-Nov-13 20:36 
QuestionData is not stored to data source path mentioned in solution explorer Pin
emma.sun.sts19-Nov-13 14:24
emma.sun.sts19-Nov-13 14:24 
AnswerRe: Data is not stored to data source path mentioned in solution explorer Pin
Richard Andrew x6419-Nov-13 17:54
professionalRichard Andrew x6419-Nov-13 17:54 
GeneralRe: Data is not stored to data source path mentioned in solution explorer Pin
emma.sun.sts19-Nov-13 18:28
emma.sun.sts19-Nov-13 18:28 
GeneralRe: Data is not stored to data source path mentioned in solution explorer Pin
Richard Andrew x6419-Nov-13 19:41
professionalRichard Andrew x6419-Nov-13 19:41 
GeneralRe: Data is not stored to data source path mentioned in solution explorer Pin
emma.sun.sts19-Nov-13 20:18
emma.sun.sts19-Nov-13 20:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.