LennieKuah
March 29th, 2010, 05:12 AM
Hi Good Guys,
I encounter another new problem using C#.Net2008. I have created CLASSConnectionString and using FrmDataGrid to instantiate it to retrieve the SQL SERVER Connection string from it. Among the coding I placed <-- Error to denounce the cause of problem.
This is the first time that I have created a CLASS like VB.NET2008 to ensure all the programe can retrieve SQLSERVER connection string. In VBNET2008 it works very well but C#.NET2008 I am struggling with it because I am new to C#.NET2008.
Please Help me. I need your help.
Here are the CLASS Coding and FRMDATAGRID coding.
--------------------------------------------------------
// ClassConnectionString coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ClassConnectionString
{
public class ClassConn
{
// declare variables
public string clsGvConnstr = "";
public String PropSQLSRVconnection()
{
clsGvConnstr += "Integrated Security=SSPI";
clsGvConnstr += "Data Source = KuahFamily\LocalHost"; <-- Error \LocalHost
clsGvConnstr += "Persist Security Info=False";
clsGvConnstr += "Initial Catalog = NorthWind";
string PropAdoconnection = clsGvConnstr;
return PropAdoconnection;
}
}
}
--------------------------------------------------
// FrmDataGrid.CS coding
using System.Data.SqlClient;
using System.Data;
namespace CShartNet2008GeneralApps
{
public partial class FrmDataGrid : Form
{
public FrmDataGrid()
{
InitializeComponent();
}
//connection variable and class instantiate
private string connstr = "";
private ClassConnectionString clsConnSrv; <-- Error ClassConnectionString
private void FrmDataGrid_Load(object sender, EventArgs e)
{
//instantiate class to retrieve Prop
clsConnSrv = new ClassConnectionString
connstr = clsConnSrv.PropSQLSRVconnection; <--- Error connstr
}
}
}
I encounter another new problem using C#.Net2008. I have created CLASSConnectionString and using FrmDataGrid to instantiate it to retrieve the SQL SERVER Connection string from it. Among the coding I placed <-- Error to denounce the cause of problem.
This is the first time that I have created a CLASS like VB.NET2008 to ensure all the programe can retrieve SQLSERVER connection string. In VBNET2008 it works very well but C#.NET2008 I am struggling with it because I am new to C#.NET2008.
Please Help me. I need your help.
Here are the CLASS Coding and FRMDATAGRID coding.
--------------------------------------------------------
// ClassConnectionString coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ClassConnectionString
{
public class ClassConn
{
// declare variables
public string clsGvConnstr = "";
public String PropSQLSRVconnection()
{
clsGvConnstr += "Integrated Security=SSPI";
clsGvConnstr += "Data Source = KuahFamily\LocalHost"; <-- Error \LocalHost
clsGvConnstr += "Persist Security Info=False";
clsGvConnstr += "Initial Catalog = NorthWind";
string PropAdoconnection = clsGvConnstr;
return PropAdoconnection;
}
}
}
--------------------------------------------------
// FrmDataGrid.CS coding
using System.Data.SqlClient;
using System.Data;
namespace CShartNet2008GeneralApps
{
public partial class FrmDataGrid : Form
{
public FrmDataGrid()
{
InitializeComponent();
}
//connection variable and class instantiate
private string connstr = "";
private ClassConnectionString clsConnSrv; <-- Error ClassConnectionString
private void FrmDataGrid_Load(object sender, EventArgs e)
{
//instantiate class to retrieve Prop
clsConnSrv = new ClassConnectionString
connstr = clsConnSrv.PropSQLSRVconnection; <--- Error connstr
}
}
}