我该如何解决这个错误? [英] How do I fix this error?

查看:63
本文介绍了我该如何解决这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试调试程序时出现CS 1061错误,似乎无法找到答案



错误CS1061'对象'不包含定义'ds'和没有扩展方法'ds'接受'object'类型的第一个参数可以找到(你是否缺少using指令或程序集引用?)游戏C:\ Visual Studio \ MYY RR GAME \ THE GAME\THGAME\Register.cs 41 Active



我的程序代码 - 错误以*错误提示表示。





I get a CS 1061 error when I try to debug the program and cant seem to find the answer

Error CS1061 'object' does not contain a definition for 'ds' and no extension method 'ds' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) THE GAME C:\Visual Studio\MY RR GAME\THE GAME\THE GAME\Register.cs 41 Active

My program code - the error is indicated with an *Error note.


namespace THE_GAME
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        DataBaseConnection objConnect;
        string conString;
        DataSet ds;
        DataRow dRow;
        

        int MaxRows;
        int inc = 0;

            

        private void Register_Load(object sender, EventArgs e)
        {
            try
            {
                objConnect = new DataBaseConnection();
                conString = Properties.Settings.Default.MemberConnectionString;

                objConnect.connection_string = conString;
                objConnect.Sql_string = Properties.Settings.Default.SQL.

       *ERROR   ds = objConnect.GetConnection;
                MaxRows = ds.Tables[0].Rows.Count;
               
              NavigateRecords();

            }
                  
                catch (Exception err)
                
            {
                MessageBox.Show(err.Message);
            }

            NavigateRecords();

          {
                    dRow = ds.Tables[0].Rows[inc];

                    textBoxFirst.Text = dRow.ItemArray.GetValue(1).ToString();
                    textBoxMI.Text = dRow.ItemArray.GetValue(2).ToString();
                    textBoxLast.Text = dRow.ItemArray.GetValue(3).ToString();
                    textBoxInit.Text = dRow.ItemArray.GetValue(4).ToString();
                    textBoxAge.Text = dRow.ItemArray.GetValue(5).ToString();
                    textBoxAddress.Text = dRow.ItemArray.GetValue(6).ToString();
                    textBoxBirth.Text = dRow.ItemArray.GetValue(7).ToString();
                    textBoxCity.Text = dRow.ItemArray.GetValue(8).ToString();
                    textBoxState.Text = dRow.ItemArray.GetValue(9).ToString();
                    textBoxZipCode.Text = dRow.ItemArray.GetValue(10).ToString();
                    textBoxCountry.Text = dRow.ItemArray.GetValue(11).ToString();
                    textBoxUserID.Text = dRow.ItemArray.GetValue(12).ToString();
                    textBoxMemberID.Text = dRow.ItemArray.GetValue(13).ToString();
                    textBoxPW.Text = dRow.ItemArray.GetValue(14).ToString();
                    textBoxPWA.Text = dRow.ItemArray.GetValue(15).ToString();
                    textBoxEmail.Text = dRow.ItemArray.GetValue(16).ToString();
                }
     
          
        }

        private void NavigateRecords()
        {
            throw new NotImplementedException();





我的尝试:



看了几个相同类型问题的帖子,但似乎没有什么匹配。



我是C#编程新手!



What I have tried:

Looked at several posts for the same type of problem, but nothing seems to match.

I' new to C# programing!

推荐答案

*ERROR ds = objConnect.GetConnection;



这应该是什么?您正在重新定义ds对象,因此它不再是DataSet引用。


What is this supposed to be? You are redefining the ds object so it is no longer a DataSet reference.


查看您的代码:

Look at your code:
objConnect.Sql_string = Properties.Settings.Default.SQL.

*ERROR ds = objConnect.GetConnection;

这两行中第一行末尾的'。'应该是分号,GetCnnection可能是一个方法,所以需要括号:

The '.' at the end of the first of those two lines should be a semicolon, and GetCnnection is probably a method, so needs brackets:

objConnect.Sql_string = Properties.Settings.Default.SQL;

ds = objConnect.GetConnection();



BTW:这不是调试 - 这是编译。当您完成编译并且您的应用程序开始运行时,调试就会开始。在代码没有编译器错误之前你不能运行(最好也没有编译器警告)。


BTW: this is not debugging - this is compiling. Debugging starts when you get through compilation and your app starts to run. You can't run until your code has no compiler errors (and preferably no compiler warnings either).


Visual C#.NET



$ b





代码应该允许用户查看数据库表的内容。复制自一本书Visual C#.NET版权所有:家庭和学习本版:2017年11月作者:Ken Carney,适合我的计划。



ds ,我认为它应该是DataSet。
Visual C# .NET





The code is supposed to allow the user to view the contents of a database table. Copied from a book "Visual C# .NET Copyright: Home and Learn This Edition: November 2017 Author: Ken Carney", adapted to fit my program.

The "ds", I assume was meant to be the DataSet.


这篇关于我该如何解决这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆