回 帖 发 新 帖 刷新版面

主题:那里出了问题啊

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication9
{
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Data.SqlClient.SqlConnection sqlConnection1;
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Form1()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null) 
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows 窗体设计器生成的代码
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
            // 
            // sqlConnection1
            // 
            this.sqlConnection1.ConnectionString = "workstation id=60678972B9C84A6;packet size=4096;integrated security=SSPI;initial " +
                "catalog=HotelManage;persist security info=False";
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);

        }
        #endregion

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {
            SqlConnection myconn= new Sqlconnection("workstation id=60678972B9C84A6;packet size=4096;integrated security=SSPI;initial catalog=HotelManage;persist security info=False;");
            SqlCommand mycom= new SqlCommand ("SELCET * FROM ROMM myconn",myconn);
           myconn.Opern();
           SqlReader myreader;
           myreader= myda.ExcuteReader();
            While( myreader.Read());
            {
             Consle.WhriteLine(  myreader.GetInt32(0)+".GetString(1)");
             myreader.Close();                      
            }
          
              myconn.Close();

         

        }
    }
}

回复列表 (共1个回复)

沙发

myconn.Opern();
->
myconn.Open();

发代码时请将出错位置标出,方便看帖者查错

我来回复

您尚未登录,请登录后再回复。点此登录或注册