SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Server=.;DataBase=Sport;Uid=sa;Pwd=123";
            string strSql;
            strSql  = "Selecte Ath_Name Into #txtName3.Text From Athlete Where Ath_Num ='"+ txtNumber3.Text+"'";
           SqlCommand cmd = new SqlCommand(strSql, conn);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();我这么有什么错误?

解决方案 »

  1.   

    SqlConnection conn = new SqlConnection();
                conn.ConnectionString = "Server=.;DataBase=Sport;Uid=sa;Pwd=123";
                string strSql;
                strSql  = "Selecte Ath_Name Into #txtName3.Text From Athlete Where Ath_Num ='"+ txtNumber3.Text+"'";
                SqlCommand cmd = new SqlCommand(strSql, conn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);懂了么?
      

  2.   

    select都拼写错了,别的就不看了。去小学三年级补课
      

  3.   

    经典的数据和UI关联方法。。            
          后台数据<--->DataContext<--->UI     任何一个前台操作不要写sql语句,否则等于垃圾代码,无法维护。。
      

  4.   


    ExecuteNonQuery用于更新,删除,添加删除操作,你这里是查询,肯定是不对的,而且大兄弟,2楼大佬说的对啊,你这select都能写错,这手动代码编写能力太恐怖了
      

  5.   

    sqlserver不支持你Into的语法            SqlConnection conn = new SqlConnection();
                conn.ConnectionString = "Server=.;DataBase=Sport;Uid=sa;Pwd=123";
                string strSql;
                strSql = "Select Ath_Name  From Athlete Where Ath_Num ='" + txtNumber3.Text + "'";
                SqlCommand cmd = new SqlCommand(strSql, conn);
                conn.Open();
                object obj = cmd.ExecuteScalar();
                txtNumber3.Text = obj.ToString();
                conn.Close();
      

  6.   

    1.SQL语句里SELECT写错。
    2.ExecuteNonQuery,你还获取什么去?
      

  7.   

    引用 1 楼 jx315425246 的回复:
    SqlConnection conn = new SqlConnection();
                conn.ConnectionString = "Server=.;DataBase=Sport;Uid=sa;Pwd=123";
                string strSql;
                strSql  = "Select Ath_Name Into #txtName3.Text From Athlete Where Ath_Num ='"+ txtNumber3.Text+"'";
                SqlCommand cmd = new SqlCommand(strSql, conn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);懂了么?ExecuteNonQuery用于更新,删除,添加删除操作,你这里是查询,肯定是不对的,而且大兄弟,2楼大佬说的对啊,你这select都能写错,这手动代码编写能力太恐怖了
    这是一个插入语句 select into 后面是表名,他可以提取出数据
      

  8.   

    ExecuteNonQuery用于更新,删除,添加删除操作,你这里是查询,肯定是不对的,而且大兄弟,2楼大佬说的对啊,你这select都能写错,这手动代码编写能力太恐怖了这是一个插入语句 select into 后面是表名,他可以提取出数据,仔细看代码。
      

  9.   

    你们怎么以为是select语句,这明明是插入,插入,插入
      

  10.   

    不好意思哈,兄弟。我看錯了,不過這個Select into複製語句sqlserver是支持的啊,反倒是在oracle數據庫中好像會出錯,具體參考https://www.cnblogs.com/mq0036/p/4155136.html#4199828
      

  11.   

    select into 是从老表里面选取或者说复制数据到一个新表里,但是新表是不能存在的,这样这个语句才会成立,而你这里应该是赋值给控件,我觉得用这个语句不太合适,发表个人看法
      

  12.   

    SQL关键字都能写错?又是select  又是into  你要干嘛?