Solved

c#.net - errors with code

Posted on 2011-09-25
8
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Bill Nolan
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 7

Expert Comment

by:Bill Nolan
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:Bill Nolan
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:Bill Nolan
ID: 36949885
So you weren't having an issue with the session var?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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