Database Reference
In-Depth Information
Figure 13-8. The Design view of the CommandNonQuery form
Listing 13-4. CommandNonOuery.cs
Using System.Data.SqlClient;
private void btnInsertCurrency_Click(object sender, EventArgs e)
{
// Create connection
SqlConnection conn = new SqlConnection(@"server = .\sql2012;
integrated security = true;
database = AdventureWorks");
// Insert Query
string sqlIns = "Insert Into Sales.Currency(CurrencyCode,Name,ModifiedDate)" +
"Values(" + "'" + txtCurrencyCode.Text + "','" +
txtName.Text + "','" + dtpModifiedDate.Value.ToString() + "')";
// Create command
SqlCommand cmd = new SqlCommand(sqlIns, conn);
try
{
// Open connection
conn.Open();
 
Search WWH ::




Custom Search