Single quote problem in SQL Server

It is a query string problem when you are coding like this

string sqlstr = “insert into UserMember (Id, Name) values(1, ” + txtName.Text + “)”

if the txtName.Text has the value like this
1. testname’
2. ‘testname
3. testn’ame

the error message will be found
– Unclosed quotation mark before the character string ‘)
– Incorrect syntax near ‘testname’ More