views:

99

answers:

3

I miss this place.

Here are snippits i wrote in C#. I would like to know if i can copy/pasting this to a asp.net app and what i may need to change. I am mostly worried that the syntax will be invalid because a compatible library doesn't exist.

struct MediaIdUserIdPair //is there a standard pair i can use?
{
    public long mediaId, userId;
};

class Media : Media_Base
{
    public long mediaId, auth;
    public DateTime currentDate;
    public List<MediaIdUserIdPair> derivedFrom, inspiredBy;
    public List<string> derivedFromStr, inspiredByStr;
    public List<string> inspiredByExt = new List<string>();
};

            command.CommandText =
                "CREATE TABLE if not exists tag_name( " +
                "tagid INTEGER PRIMARY KEY, " +
                "title TEXT UNIQUE);";
            command.ExecuteNonQuery();
                command.CommandText = 
                    "INSERT OR FAIL INTO tag_name(title) VALUES(@title); " +
                    "SELECT last_insert_rowid() AS RecordID;";
                command.Parameters.Add("@title", DbType.String).Value = tag;
                long tagid = (long)command.ExecuteScalar();
A: 

I don't see anything in the code samples that would need to change.

Basically, as long as your asp.net app targets the same version of the framework as your c# app, you should be good to go.

Jimmie R. Houts
That is great to know :)
acidzombie24
A: 

Which part are you concerned about? It looks like standard C# to me; there's no reason it wouldn't work in whatever application type you want, as long as you reference the relevant libraries. (System.Data, etc.)

GalacticCowboy
A: 

Your partial snippet doesn't contain any non-ASP.NET compatible code. You can use any custom objects and ADO.NET from within either ASP.NET, WinForms and WPF. As they are all libraries that run on top of the .NET Framework and the CLR.

You may want to pick up one of the many good books on ASP.NET and/or C# that are available. It sounds like you are fairly new to .NET and there are plenty of things that are worth learning.

Chris Pietschmann
This is more of a one time project with ASP.NET, i was just worried that i made it hard for myself. I am actually using Sqlite and wasnt sure if the library is totally compatible. If the above is compatible then 90%+ of my code should be compatible. And i am unsure what is .NET and what isnt. I was told to stay away from winform (which is considered part of .NET?). Good thing is all is a way to output and insert basic data. textboxes work great for me.
acidzombie24
Yes, ASP.NET, Windows Forms and WPF are ALL part of the .NET Framework. Those three are essentially the Presentation parts of .NET. I really suggest you get some books on ASP.NET and/or .NET and read up; there seems to be plenty for you to learn.
Chris Pietschmann