Zakir Ahamed

Zakir Ahamed

  • NA
  • 1.4k
  • 625.9k

my connection string is not working

Jul 21 2017 3:16 AM
this my code:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using Sample;
 
 
if (txtcategory.Text != " ")
{
try
{
ConnectionString con = ConfigurationManager.ConnectionStrings["RetailTestConnection"].ToString();
con.Open();
string query = String.Format("Select [Item_Id]='{0}' order by Item_Id", txtcategory.Text);
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
string[] s = new string[] { };
while (dr.Read())
{
s = dr["Items"].ToString().Split(',');
}
int Length = s.Length;
for (int i = 0; i < Length - 1; i++)
// for (int i = 0; i <= 1; i++)
{
string fetr = s[i];
for (int j = 0; j <= clbbrand.Items.Count - 1; j++)
{
if (clbbrand.Items[j].ToString() == s[i])
{
clbbrand.SetItemChecked(j, true);
break;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
else
{
// Message.Show("Please Eneter Your Choice");
}
 
 
 
note error:
 
the type or namespace name 'Connection string'  could not be found
 

Answers (2)