C# sqlite syntax in ASP.NET?

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2009-05-04T23:04:31Z Indexed on 2010/04/06 22:53 UTC
Read the original article Hit count: 223

Filed under:
|
|

-edit- This is no longer relevant and the question doesnt make sense to me anymore. I think i wanted to know how to create tables or know if the syntax is the same from winform to ASP.NET


I am very use to sqlite http://sqlite.phxsoftware.com/ and would like to create a DB in a similar style. How do i do this? it doesnt need to be the same, just similar enough for me to enjoy.

An example of the syntax.

connection = new SQLiteConnection("Data Source=" + sz +";Version=3");
command = new SQLiteCommand(connection);

connection.Open();

command.CommandText =
   "CREATE TABLE if not exists miscInfo(key   TEXT, " +
   "value TEXT, UNIQUE (key));";
command.ExecuteNonQuery();

The @name is a symbol and command.Parameters.Add("@userDesc", DbType.String).Value = d.userDesc; replaces the symbol with escaped values/texts/blob

command.CommandText = 
   "INSERT INTO discData(rootfolderID, time, volumeName, discLabel, " + 
   "userTitle, userDesc) "+
   "VALUES(@rootfolderID, @time, @volumeName, @discLabel, " + 
   "@userTitle, @userDesc); " +
   "SELECT last_insert_rowid() AS RecordID;";

command.Parameters.Add("@rootfolderID", DbType.Int64).Value = d.rootfolderID;
command.Parameters.Add("@time", DbType.Int64).Value = d.time;
command.Parameters.Add("@volumeName", DbType.String).Value = d.volumeName;
command.Parameters.Add("@discLabel", DbType.String).Value = d.discLabel;
command.Parameters.Add("@userTitle", DbType.String).Value = d.userTitle;
command.Parameters.Add("@userDesc", DbType.String).Value = d.userDesc;

d.discID = (long)command.ExecuteScalar();

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlite