Database Reference
In-Depth Information
•
For the Location property, set X to 12 and Y to 12.
•
For the Size property, set Width to 456 and Height to 135.
•
Leave the Text property blank.
4.
Now your LoadText form in the Design view should look like Figure 17-6.
Figure 17-6.
The Design view of the LoadText form
5.
Next, insert the code in Listing 17-5 into
LoadText.cs
. You can access
LoadText.cs
by right-clicking
LoadText.cs
and selecting View Code, which will
take you to the Code view.
Listing 17-5.
LoadText.cs
using System.Data;
using System.Data.SqlClient;
using System.IO
static string fileName =
@"C:\VidyaVrat\C#2012 and SQL 2012\Chapter17\Code\Text and Binary Data\LoadText.cs";
SqlConnection conn = null;
SqlCommand cmd = null;
public LoadText()
{
InitializeComponent();
}
private void LoadText_Load(object sender, EventArgs e)
{
try
{
// Create connection
conn = new SqlConnection(@"data source = .\sql2012;
integrated security = true;initial catalog = SQL2012Db;");
//Create command