Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Shadoblaque

@Shadoblaque
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C# books
    S Shadoblaque

    List<T> could be employed here (such as List<Asset>). AddRange won't work in this case however, as it is not an ICollection that is being added.   So, while: result.AddRange(assets.Rows); would work (if Rows was to be returned), this line: result.AddRange(new Asset(dr)); would not.   (Did you miss that Asset was a class constructor with the row as a parameter?)   The returning value in this case is a collection of Asset objects (I have not defined the Asset class here, I just provided the snippet as an example of MS Access interaction).

    C# database csharp sql-server sysadmin question

  • C# books
    S Shadoblaque

    The SQL syntax is very similar, if that's what you are asking. Learning SQL is not the same thing as learning C#, of course. Here's another example that builds upon the previous one (where coreDB is a class containing the previous code, and the call to Asset is a constructor for another class in the example project that builds from the specific data row). The uppercase component in this one is the SQL used in querying MS Access. /// <summary> /// Gets the object array of inventory items. /// </summary> /// <param name="orgID">Int ID of the organization.</param> /// <returns>An arraylist of inventory item listings.</returns> public ArrayList GetOrgAssets(int orgID) { ArrayList result = new ArrayList(); DataTable assets = coreDB.ExecuteQuery ("SELECT * FROM ORGANIZATION_ASSETS WHERE ORGANIZATION_FK = "+orgID.ToString()+";"); foreach (DataRow dr in assets.Rows) result.Add(new Asset(dr)); return result; }

    C# database csharp sql-server sysadmin question

  • C# books
    S Shadoblaque

    Well, one book that I have found useful is Deitel's C# for Programmers (ISBN 0-13-134591-5). That's what I started with. Concerning MS Access, here is some code that may help you get started: OleDbConnection jetDB = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + AccessFileFullPath + "'"); /// <summary> /// Handles SQL commands that do not return results, such as CREATE, /// INSERT, or DELETE. /// </summary> /// <param name="SQL">SQL command string (must terminate with semicolon).</param> public void ExecuteNonQuery(string SQL) { OleDbCommand executeCommand = new OleDbCommand(SQL, jetDB); jetDB.Open(); executeCommand.ExecuteNonQuery(); jetDB.Close(); } /// <summary> /// Retrieves data from the specified table or query, using the SQL string /// passed as a parameter. /// </summary> /// <param name="query">SQL string to execute to obtain the Data Table.</param> /// <returns>A data table populated with the specified query.</returns> public DataTable ExecuteQuery(string query) { DataTable queryResult = new DataTable(); OleDbDataAdapter queryDBA = new OleDbDataAdapter(query, jetDB); queryDBA.Fill(queryResult); return queryResult; }

    C# database csharp sql-server sysadmin question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups