|
You should be able to use last_insert_rowid for the last row id that was inserted for that connection. Basically, inside the same connection, issue a separate select command:
SELECT last_insert_rowid
|
|
|
|
|
Hi Pete,
I tried this and it wont let me compile. I don't know the correct syntax. There is not much out there for WP8 SQLite
string query = "select last_insert_rowid() as id from myTable";
using (var db = new SQLite.SQLiteConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "SM.db"), true))
{
SQLite.SQLiteCommand cmd = new SQLite.SQLiteCommand(db);
var result = cmd.ExecuteNonQuery();
}
|
|
|
|
|
No. Only select last_insert_rowid();. You don't need the rest. There's a reaaon I didn't include it in my answer there.
|
|
|
|
|
I tried that and I get this error
SQLite.SQLiteException: Misuse
|
|
|
|
|
I tried this also and the error is "Row"
SQLite.SQLiteCommand cmd = new SQLite.SQLiteCommand(db);
cmd.CommandText = query.ToString();
var result2 = cmd.ExecuteNonQuery();
|
|
|
|
|
If you're trying to retrieve the record, use ExecuteScalar , not ExecuteNonQuery .
|
|
|
|
|
Ok,
So what is the syntax for that?
cmd.ExecuteScalar< ? >;
Sorry, I just don't know SQLite
|
|
|
|
|
It should just be something like:
private int GetLastRowId(SQLLite.SQLLiteConnection connection)
{
SQLLite.SQLLiteCommand cmd = new (connection);
cmd.CommandText = "SELECT last_insert_rowid";
object rowId = cmd.ExecuteScalar();
return Convert.ToInt32(rowId);
}
|
|
|
|
|
|
|
Cursor cursor = getReadableDatabase().
rawQuery("select * from todo where _id = ?", new String[] { id });
|
|
|
|
|
Hello
I need your help ...
How can I invoke an HTTPS web service from J2ME??
Suppose there is a HTTPS site contains a web service , and I want to invoke this web service from a J2ME Application exists in my mobile phone , How I can do that ???
Please Any helpful Article or project or Video send me...
Thank you all..
I am waiting your reply.....
|
|
|
|
|
Hello,
Here[^] is a good tutorial available on IBM Developerworks.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Thank you Prasad P. Khandekar
I ll read chapters ...
|
|
|
|
|
I have a Windows Phone 8 App using SQLite (C#, XAML) I want to create records in my table in code. I tried an experiment by just placing a button on my window that executes a counter to create 10 records in my database. When I execute it, I get no errors, but the records are not in the database. Could you tell me what I am doing wrong?
For instance, with my DataModel:
class Test
{
[SQLite.AutoIncrement, SQLite.PrimaryKey]
public int TestID { get; set; }
public int MyCounter { get; set; }
}
And my View Model
public class TestViewModel : ViewModelBase
{
#region Properties
private int testid = 0;
public int testid
{
get
{ return testid; }
set
{
if (testid == value)
{ return; }
testid = value;
RaisePropertyChanged("TestID");
}
}
private int mycounter = 0;
public int MyCounter
{
get
{ return mycounter ; }
set
{
if (mycounter == value)
{ return; }
mycounter = value;
RaisePropertyChanged("MyCounter");
}
}
#endregion
public string SaveRecord(TestViewModel _vm)
{ string result = string.Empty;
using(var db = new SQLite.SQLiteConnection(app.DBPath))
{
string change = string.Empty;
try
{
var er = (db.Table().Where(
c => c.TestID == _vm.TestID)).SingleOrDefault();
if (er != null)
{
er.MyCounter = _vm.MyCounter;
int success = db.Update(er);
}
else
{
int success = db.Insert(new Test()
{
TestID = _vm.TestID,
MyCounter = _vm.MyCounter,
});
}
result = "Success";
}
catch (Exception ex)
{
StringBuilder erMessage = new StringBuilder();
erMessage.Append("This record was not saved.");
erMessage.AppendLine();
erMessage.Append(ex);
result = "This record was not saved.";
}
}
return result;
}
}
So in my Window I just tried a test
public partial class MyWindow : PhoneApplicationPage
{
RoundShotTest mytest = null;
…..
….
}
private void buttonTryMe_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
For(int x = 0; x < 10; x++)
{
mytest = new TestViewModel();
mytest.MyCounter = x;
string result = mytest.SaveRecord(mytest);
}
What am I doing wrong here. I get no error, but when I take a look in the database, the records have not been written?
|
|
|
|
|
Where do you look in the database? In your debug directory, or in the directory it was originally in? When you develop an application in Visual Studio, the Compile Options (in the Properties page for a particular file) tell you whether or not the file is going to be copied to a different location. Immediately after your loop, select a count of the records to see how many there are.
|
|
|
|
|
Hi Pete,
The db file itself is marked Build Action is set as Content, and Copy to Output Directory is set as Copy if Newer.
In my App.xaml I have:
public partial class App : Application
{
public static IsolatedStorageSettings myappsettings = IsolatedStorageSettings.ApplicationSettings;
private string dbName = "SM.db";
public const string ConnectionString = @"isostore:/SM.db";
private string dBPath = string.Empty;
public static SQLiteAsyncConnection Connection { get; set; }
public string DBPath
{
get
{ return dBPath; }
set
{
if (dBPath == value)
{ return; }
dBPath = value;
}
}
Whats even more weird is that I did this on another app, without the exception of the counter, and it worked. I'm lost?
|
|
|
|
|
Recently, i hired a developer to develop a game for iphone and ipad for me but now i'm quite worry that he will submit it before give it to me, so what can i do to avoid this.
|
|
|
|
|
We are just developers not leagal adviseres...
|
|
|
|
|
I don't know why the 1 voted But I 5'd to make up for it.
Frazzle the name say's it all
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods
|
|
|
|
|
My advice would be to contact a lawyer. I also would consider contacting the apple store.
Frazzle the name say's it all
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods
|
|
|
|
|
I think you such practice is very dangerous, their own electronic products contain their own privacy, it is best not to give others repair esky
|
|
|
|
|
Hi, I am using Sencha. I have created the application and I hosted in server and I can able to search the URL in mobile. Now my question is, I want download my full project files at first time like mobile application and want to install it. How to acheive this?
|
|
|
|
|
|
Hi experts,
I am new to android development.
I want to develop application locker.
In this application i want to set password protection for applications like message, phonebook...
I can get forground application from list of running application, using ActivityManagerclass. Now i want to keep this process running continuously in background so i will make use of service.
But i want to check for running applications list after every second, so my service will be starting and stopping in every second. Is this correct way to implement using service?
And i think after 4.0 android version in idle state system stops services, so how to keep service alive?
Please suggest me correct way to implement this application.
Thanks in advance.
|
|
|
|