For starters, don't do it like that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("INSERT INTO [Table] (StudentId, StudentName) VALUES (@ID, @NM)", con))
{
cmd.Parameters.AddWithValue("@ID", textBox1.Text);
cmd.Parameters.AddWithValue("@NM", textBox2.Text);
cmd.ExecuteNonQuery();
}
}
Once you have done that, check your connection string. Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.
Then, check your names and columns: "Table" is an unlikely name for a table, and the two columns you reference use different naming conventions, so it's likely that one of them is wrong as well.
Check the datatypes: are they text? I.e. in SQL Server are they declared as VARCHAR or NVARCHAR? How big are they? Are they INT, or FLOAT instead?
And look at the exception: use the debugger to examine what it says is going on - SQL error message can be unhelpful, but they do give clues.