Solved

c#.net - errors with code

Posted on 2011-09-25
8
225 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: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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 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