problem with dataAdapter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MCPD
    New Member
    • Feb 2007
    • 29

    #1

    problem with dataAdapter

    Hello

    i have this code

    DataAdapter = new SqlDataAdapter( "select name from CDS where Id='" + TextBox1.Text + "'", mycon);

    how can i view the value in textbox 2 ??????????????? ??

    i mean the value that returned from the sql

    the value of name's Column
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Have you tried executing the command? Please post the code that you are using and any errors that you are receiving. Thanks.

    Comment

    • MCPD
      New Member
      • Feb 2007
      • 29

      #3
      i know that if i use sqlCommand i can use excute

      but if i have a dataAdapter i cant excute it

      this the full Code

      Code:
      public partial class _Default : System.Web.UI.Page 
      {
          DataSet MyDataSet = null;
          SqlConnection mycon = null;
          SqlDataAdapter DataAdapter = null;
          protected void Page_Load(object sender, EventArgs e)
          {
              mycon = new SqlConnection("Data Source=.;Initial Catalog=CDDB;Integrated Security=True");
              DataAdapter = new SqlDataAdapter("select name from CDS where Id='" + TextBox1.Text + "'", mycon);
              MyDataSet = new DataSet();
              DataAdapter.Fill(MyDataSet);
          }
          protected void Button1_Click(object sender, EventArgs e)
          {
              if (MyDataSet.Tables[0].Rows.Count>0)
              {
                  [B][I]TextBox2.Text = "" +[/I][/B]
              }
          }
      }
      what i should to type here
      TextBox2.Text = "" +

      to get what returned the adapter and put it into textbox2 ?!?!?!

      Comment

      • radcaesar
        Recognized Expert Contributor
        • Sep 2006
        • 759

        #4
        Try to use Datagrid there.

        Since the returned object which u r trying to use is DataSet, not string.

        If u want to work around (To make it as string and then assign it to the text box with some RegEx in between the data), then u have to navigate the dataset by dataset-->Table-->Column-->Row-->Value

        :)

        Comment

        • kenobewan
          Recognized Expert Specialist
          • Dec 2006
          • 4871

          #5
          radcaesar is right, otherwise if you want to write to string you will need to use a datareader instead.

          Comment

          • MCPD
            New Member
            • Feb 2007
            • 29

            #6
            can u please tell me how to get string not data set ?

            can u write the code because i am new in c# just 2 month learning ??

            thanx very much

            Comment

            • MCPD
              New Member
              • Feb 2007
              • 29

              #7
              any help????

              Comment

              • RedSon
                Recognized Expert Expert
                • Jan 2007
                • 4980

                #8
                Originally posted by MCPD
                can u please tell me how to get string not data set ?

                can u write the code because i am new in c# just 2 month learning ??

                thanx very much
                No one is going to write the code for you. You need to be responsible for your own work. As suggested above to get string information you might be able to use DataReader, by the same token if you wanted to make string information you might try searching for something like a DataWriter. It seems logical that those two classes might have similar functionality except in different directions.

                Comment

                • MCPD
                  New Member
                  • Feb 2007
                  • 29

                  #9
                  thanx alot for u all

                  i learned new things from u all

                  i searched about the dataReader at the internet and i learn it

                  if any one have any info. about DataWriter i will thankfull

                  thnx for all moderators

                  Comment

                  Working...