   [.net] asp.net Driving me insane........
  Hey, I can't seem to find one example of code inserting data into a SQLDatabase. It's like everyone that wrote a tutorial just thought o well the person will automatically know what to do so we'll just leave this out! It's getting me really mad. I have been searching forever. Not even microsofts offical asp.net page has actual C# code of asp.net inserting data in SQL. If anyone knows of one please let me know b/c this is just plain frusterating.   
  You might get more (or, at least, better) help somewhere besides the Lounge. It's worth a shot right? So, off we go...   ;  It should be pretty simple.  You can perform an insert almost exactly like a select, which is probably what you have seen in a lot of tutorials.My experience is with Sybase database, so I'll post some sample code using the Sybase ASE library.  It should be easy enough to switch AseXYZ to SqlXYZ or OdbcXYZ(or whatever database flavor you're using).using(AseConnection conn = new AseConnection("<<<connection string goes here>>>")){conn.Open();using(AseCommand command = new AseCommand(conn)){command.CommandType = CommandType.Text;command.CommandText = "insert into MYTABLE (FIRST, SECOND, THIRD) values (1, "abc", null)";int rowsInserted = command.ExecuteNonQuery()}}I didn't include any error checking, and you would probably want to use command parameters, rather than including them in the CommandText property, but hopefully you get the idea.- Mike   ;  Thanks for the input, this is my code, it compiles right but it fails to actually insert a row.objCommand = new SqlCommand("INSERT into myImages(img_loc) VALUES(" + File1.Value + ")", objConnect); objCommand.BeginExecuteNonQuery(); Status.InnerHtml = "<font color=\'red\'>Successfully uploaded your file ( " + File1.Value + " )</font>";Thanks again   ;  A few remarks:- why are you using BeginExecuteNonQuery ? Unless there's a good reason you should be using ExecuteNonQuery. If you go for the asynch route and use Begin..., then you msut also call EndExecuteNonQuery. And you don't know if the call was successful until you do so.- What type is the field img_loc ?If it's a string, you should quote the SQL value between ' '. E.g.:INSERT INTO myImages (img_loc) VALUES ( 'blabla' )So your example may be:"INSERT INTO myImages (img_loc) VALUES ('" + File1.Value + "')"- But take great care! What happens if File1.Value contains a ' ? Inserting user input into a SQL command should never be done. Some user input may provoke error (example: "jods' bad input"), and even worst, some user may take advantage of that to attack your system (this is call SQL injection). Example, I suppose syntax is SQL Server: if I enter "blabla'); DELETE FROM myImages; --" I would have erased your whole myImages table. Surely not something you want. The solution is to use SQL parameters. Look it up on google or MSDN.- Finally, seeing your code, I wonder if img_loc is a BLOB. If it is, you should look it up on google/MSDN, because uploading BLOB to a database is usually more complicated than executing an INSERT (there is some specific methods for BLOBs).I hope this helps,jods   ;MSDN is your friend. But here is my database independant code :#region Database Specific   private DbCommand Command   {  get  { DbProviderFactory factory = DbProviderFactories.GetFactory(connectionSettings.ProviderName); DbConnection connection = factory.CreateConnection(); connection.ConnectionString = connectionSettings.ConnectionString; DbCommand command = connection.CreateCommand(); return command;   }   }   protected DbParameter GetParameter(string name, object value)   {  DbCommand command = Command;  DbParameter parameter = command.CreateParameter();  parameter.ParameterName = name;  parameter.Value = value;  return parameter;   }   private DbCommand GetCommand(string query)   {  DbCommand command = Command;  command.CommandText = query;    return command;   }   private DbCommand GetCommand(string query, params DbParameter[] parameters)   {  DbCommand command = Command;  command.CommandText = query;  foreach (DbParameter parameter in parameters)  { command.Parameters.Add(parameter);  }  return command;   }   protected object ExecuteScalar(string query)   {  DbCommand command = GetCommand(query);  command.Connection.Open();  object o = command.ExecuteScalar();  command.Connection.Close();    if (o == DBNull.Value) return null;  return o;}   protected object ExecuteScalar(string query, params DbParameter[] parameters)   {  DbCommand command = GetCommand(query, parameters);  command.Connection.Open();  object o = command.ExecuteScalar();  command.Connection.Close();  if (o == DBNull.Value) return null;  return o;   }   protected DbDataReader ExecuteReader(string query, params DbParameter[] parameters)    {  DbCommand command = GetCommand(query, parameters);  command.Connection.Open();  DbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);  return reader;   }   #endregionYour data-provider and connection string are specified in the web.config file. Using code above you can retrieve or insert data in a fast and db-independant way, like this string query = string.Format("select prd_id from product2category where cto_id={0}CategoryID", paramPrefix);  DbDataReader reader = ExecuteReader(query,  GetParameter("CategoryID", category.ID));Jods is right, never(!!) use SQL inlining, always use parameters. About blob data, this is the way I upload files:byte[] data = new byte[fileLength];file.InputStream.Read(data, 0, fileLength);Guid id = Guid.NewGuid();CMSManager.InsertFile(id, name, data, fileLength, DateTime.Now, extension, file.ContentType, SiteID);and in CMSManager I just use the same method as above, but instead executereader, I use ExecuteNonQuery. Hope this helps,Edo   