title: INSERT from ASP.NET to MS Access
body: <p>We are trying to build a Help Desk ticketing system just for intranet. Deciding upon the ASP .NET (C#) with Visual Studio 2008 Express (think we have a full version floating around if we need it). Nothing fancy, couple of pages grabbing NTLM information, system information and storing it along with their problem in a database. Goal is to make it simple, but instead of using our SQL Server 2000 back end, the admin wants me to use MS Access. I have the GridView and connections running smooth. Can pull select queries until my heart is content. However, tying in a couple variables with a text box on a submit button into say an INSERT statement.. well I don't even know where to begin with MS Access. Every internet example is in VB .NET plus seems to be hand coding what Visual Studio has already done for me in a few clicks.</p>
  
  <p>Is MS Access going to be too hard for all we want to do? If not, where do we begin to simply submit this data into the tables?</p>
  
  <p>Edit: After a bunch of playing around we have the OleDB working. It's not pretty, yes SQL Server would be awesome but, sometimes you just have to play ball.</p>
  
  <p>Edit: Anyone looking for an actual coded answer, here you are. There has got to be others out there in the same boat.</p>
  
  <pre><code>    string userIP = Request.UserHostAddress.ToString();
      string userDNS = Request.UserHostName.ToString();
      string duser = Request.ServerVariables["LOGON_USER"];  //NTLM Domain\Username
      string computer = System.Environment.MachineName.ToString(); //Computer Name
      string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\helpdesk.MDB;";
  
      OleDbConnection conn = new OleDbConnection(connectionString);
      conn.Open();
      OleDbCommand cmd = new OleDbCommand();
      cmd.Connection = conn;
      cmd.CommandText = "INSERT INTO ticketing ([user], [comp], [issue]) VALUES (@duser, @computer, @col3)";
      cmd.Parameters.Add("@duser", OleDbType.VarChar).Value = duser;
      cmd.Parameters.Add("@computer", OleDbType.VarChar).Value = computer;
      cmd.Parameters.Add("@col3", OleDbType.LongVarChar).Value = TextBox1.Text;
      cmd.ExecuteNonQuery();
      conn.Close();
  </code></pre>