Solved

c#.net - errors with code

Posted on 2011-09-25
8
219 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 7

Expert Comment

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

Good luck :)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Author Comment

by:GlobaLevel
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
So you weren't having an issue with the session var?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hangfire / asp.net sample 3 27
LINQ question 7 20
c# code 19 56
display data in text field from data base for updating 6 24
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

5 Experts available now in Live!

Get 1:1 Help Now