Solved

c#.net - errors with code

Posted on 2011-09-25
8
223 Views
Last Modified: 2013-12-17
I have an error with this line:

DataSet Tbl = new DataSet();

also
   TC_ID == Session["SessionTC_ID"];
                MyDropDown = DropDownList1;
if (flag == "dataset")
        {

            try
            {
                DropDownList MyDropDown = default(DropDownList);
                string TC_ID = null;
                string sqlConnection = null;
                TC_ID == Session["SessionTC_ID"];
                MyDropDown = DropDownList1;


                using (SqlConnection sqlConn = new SqlConnection())
                {
                    sqlConnection = "Data Source=xx.xx.xx.xx;Initial Catalog=sddasdas;Trusted_connection=true;";
                    sqlConn.ConnectionString = sqlConnection;
                    string SQLstring = "SELECT distinct(campaign_name) FROM  campaign WHERE TC_ID = '" + TC_ID + "'";
                    SqlDataAdapter TblAdaptar = new SqlDataAdapter(SQLstring, sqlConn);
                    DataSet Tbl = new DataSet();
                    Tbl.Clear();
                    try
                    {
                        TblAdaptar.Fill(Tbl);
                        MyDropDown.DataSource = Tbl;
                        MyDropDown.DataBind();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }

Open in new window

0
Comment
Question by:GlobaLevel
8 Comments
 
LVL 3

Accepted Solution

by:
afsarsal earned 500 total points
ID: 36596315
can you give the error description.
Did you add using System.Data; row at the top of page
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 36596354
here is one:
 ArrayList myArray = new ArrayList();
the type or namespace could not be found(are you missing an directive or namespace reference?)

I believe I am adding the right namespace:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Data.SqlClient;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.Security.Cryptography;
using System.data;
 
 
0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 36596355
You are using a comparison operator and you need to cast object to string.
TC_ID = (string)Session["SessionTC_ID"];

afsaral is probably correct on the other.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 7

Expert Comment

by:Slimfinger
ID: 36596358
Add a reference to the dll.  (Right click 'references' in Solution Explorer.)

Good luck :)
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 36596364
good suggestion...but im curious why I need to add a reference to the dll , in my vb.net projects I dont have to do this..
0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 36596391
The compiler needs to know where the code for the namespace is.
I don't know if VB somehow automates this.
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 36597214
Hi,

For Arraylist:
using System.Collections;

Open in new window


For DataSet:
using System.Data;

Open in new window

0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 36949885
So you weren't having an issue with the session var?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now