線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1156
推到 Plurk!
推到 Facebook!

求助,请帮我看看下面这个问题,谢谢!

尚未結案
lsh998
中階會員


發表:163
回覆:138
積分:60
註冊:2005-01-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-03-14 17:28:55 IP:219.128.xxx.xxx 未訂閱
问题1: oleDbCommand1.Parameters.Add("@sno" ,OleDbType.VarChar,50).Value=textBox1.Text; 可以 为什么 sqlCommand1.Parameters.Add("@sno" ,OleDbType.VarChar,50).Value=textBox1.Text; 就不行呢? 如果用 sqlCommand1 的话,OleDbType.VarChar 应该改为什么? 问题2: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using System.Data.SqlClient; private void button2_Click(object sender, System.EventArgs e) { DataTable dt = new DataTable(); DataSet ds = new DataSet(); sqlCommand1.CommandText="procselecttest8"; sqlCommand1.CommandType=CommandType.StoredProcedure; sqlCommand1.Connection=sqlConnection1; sqlCommand1.Parameters.Add("@sno" ,dbType.VarChar,50).Value=textBox1.Text; if (sqlConnection1.State != ConnectionState.Open) sqlConnection1.Open(); sqlCommand1.ExecuteReader(); SqlDataAdapte da = new SqlDataAdapter(sqlCommand1); da.Fill(ds); dt = ds.Tables[0]; this.dataGrid1.DataSource=dt.DefaultView; oleDbConnection1.Close(); } 为什么: SqlDataAdapte da = new SqlDataAdapter(sqlCommand1); 这句也有错误呢? 提示的错误是: C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WindowsApplication15\Form1.cs(228): The type or namespace name 'da' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WindowsApplication15\Form1.cs(224): The type or namespace name 'dbType' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WindowsApplication15\Form1.cs(227): The type or namespace name 'SqlDataAdapte' could not be found (are you missing a using directive or an assembly reference?) 我这段程序的作用是希望通过 datagrid1 把存储过程的到的数据集显示出来! 我是那里做错了呢? 谢谢!
wodahs
初階會員


發表:0
回覆:33
積分:26
註冊:2004-02-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-03-14 18:06:21 IP:211.72.xxx.xxx 未訂閱
問題1. SqlDbType.VarChar 問題2. 打錯字. sqlCommand1.Parameters.Add("@sno" ,dbType.VarChar,50).Value=textBox1.Text; 修正成 sqlCommand1.Parameters.Add("@sno" ,SqlDbType.VarChar,50).Value=textBox1.Text; SqlDataAdapte da = new SqlDataAdapter(sqlCommand1); 修正成 SqlDataAdapter da = new SqlDataAdapter(sqlCommand1); wodahs ====================================================================== 我是非出身科班的菜鳥,瞎子摸象,寫錯的地方,請大家包涵包涵,不要太認真 ^^ 歡迎大家批評指教,適時糾正我錯誤觀念,這樣我才會進步並學到正確的知識 ^^ ====================================================================== 發表人 - wodahs 於 2005/03/14 18:08:46
lsh998
中階會員


發表:163
回覆:138
積分:60
註冊:2005-01-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-03-15 10:18:43 IP:219.128.xxx.xxx 未訂閱
非常感谢 wodahs大哥哦^_^!
系統時間:2024-05-19 7:27:07
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!