INSERT Example


	String ^sTemp = "INSERT INTO myTable (	\
					SomeValueColumn,	\
					SomeStringColumn	\
				) Values (					\
				@SomeValue,					\
				@SomeString					\
				)";
	Command1->CommandText = sTemp;
	//Strings should be added as parameters to avoid sanatisation risks unless you know they are safe.
	//Other values can be added as parameters too or inline in the INSERT text.
	Command1->Parameters->AddWithValue("@SomeValue", 1234);
	Command1->Parameters->AddWithValue("@SomeString", "Hello");

	Command1->ExecuteNonQuery();

INSERT OR REPLACE

Add if it doesn't exist or update if it does already exist


	INSERT OR REPLACE INTO table(column_a, column_b) VALUES(value_a, value_b);

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *