Ошибка компилятора cs0115

Permalink

Cannot retrieve contributors at this time

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS0115

Compiler Error CS0115

07/20/2015

CS0115

CS0115

a0e4bd8a-a6c2-4568-8ea5-8bb1d2ad0e95

Compiler Error CS0115

‘function’ : no suitable method found to override

A method was marked as an override, but the compiler found no method to override. For more information, see override, and Knowing When to Use Override and New Keywords.

Example

The following sample generates CS0115. You can resolve CS0115 in one of two ways:

  • Remove the override keyword from the method in MyClass2.

  • Use MyClass1 as a base class for MyClass2.

// CS0115.cs
namespace MyNamespace
{
    abstract public class MyClass1
    {
        public abstract int f();
    }

    abstract public class MyClass2
    {
        public override int f()   // CS0115
        {
            return 0;
        }

        public static void Main()
        {
        }
    }
}

C# Compiler Error

Error CS0115 – ‘function’ : no suitable method found to override

Reason for the Error

You would receive this error when you mark the method as override whereas the compiler could not find method to override.

For example, try compiling the below code snippet.

abstract public class Class1
{
    public abstract void Function1();
}
abstract public class Class2 
{
    override public void Function1()  
    {
    }
}
public class DeveloperPublish
{
    public static void Main()
    {

    }
}

The class2 contains the function Function1 which has the override as keyword but there is no method to override as it doesnot have any base class to inherit from.

Error CS0115 ‘Class2.Function1()’: no suitable method found to override ConsoleApp1 C:UsersSenthilsourcereposConsoleApp1ConsoleApp1Program.cs 7 Active

C# Error CS0115 – 'function' : no suitable method found to override

Solution

You can fix it by making sure that you are inheriting the right base class which contains the method to override.

  • Remove From My Forums
  • Question

  • User148620 posted

    I’m binding this library:

    https://github.com/mancj/MaterialSearchBar

    And generally it works, however, I have an issue when I try to add the support of the RecyclerView, I added the following libraries:

    And I got the following errors:

    I tried to follow this advice of creating some partial classes:

    https://stackoverflow.com/questions/45754424/xamarin-android-binding-thorw-does-not-implement-inherited-abstract-member-rec

    But it didn’t work and I started to get duplicates, personally, I believe the main issue is here:

    Severity Code Description Project File Line Suppression State
    Error CS0115 ‘SuggestionsAdapter.OnBindViewHolder(Object, int)’: no suitable method found to override Xamarin-MaterialSearchBar C:UsersfedersourcereposXamarin-MaterialSearchBarXamarin-MaterialSearchBarobjReleasegeneratedsrcCom.Mancj.Materialsearchbar.Adapter.SuggestionsAdapter.cs 666 Active

    This is the configuration of my VS:

    The only dependencies in the Gradle of the project are the following ones:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        testImplementation 'junit:junit:4.12'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.android.support:cardview-v7:28.0.0'
    }
    

    If you want the compiled aar file and the project to test it.

    Which as you can see I have them all. Any idea, what am I missing? Thanks.

Answers

  • User148620 posted

    How to fix this issue? Technically, it’s not so simple, the best solution and there are 6 steps to follow:

    1. Add the following NuGet Packages:

      • Xamarin.Android.Support.v7.AppCompat
      • Xamarin.Android.Support.v7.CardView
      • Xamarin.Android.Support.v7.RecyclerView

      These are the minimum requirements found in the build.gradle.

    2. Remove the class SuggestionsAdapter from the future library from your Metadata.xml with this piece of code (inspired by the Leo Zhu — MSFT’ answer).

      <remove-node path="/api/package[@name='com.mancj.materialsearchbar.adapter']/class[@name='SuggestionsAdapter']" />

      Why? Because this section of the code is not properly ported to C# by the binder; perhaps, the reason is that the V represents the RecyclerView.ViewHolder and it’s too generic for the binder. You can see the original code here: SuggestionsAdapter.java

      Also, you might ask why I chose to migrate the SuggestionsAdapter over the DefaultSuggestionsAdapter. There are 2 reasons:

      • SuggestionsAdapter is the base class.
      • DefaultSuggestionsAdapter calls XML codes that you cannot access from C#, you can see them in the lines 34, 55 and 56.
    3. Build your library.

    4. Create a new folder in your Additions called Adapter where you need to create a class called SuggestionsAdapter.

    5. Migrate the code from Java to C#.

      namespace Com.Mancj.Materialsearchbar.Adapter
      {
          public abstract class SuggestionsAdapter<S, V> : RecyclerView.Adapter, IFilterable
          {
              private readonly LayoutInflater Inflater;
              protected List<S> Suggestions = new List<S>();
              protected List<S> Suggestions_clone = new List<S>();
              protected int MaxSuggestionsCount = 5;
      
              public void AddSuggestion(S r)
              {
                  if (MaxSuggestionsCount <= 0)
                  {
                      return;
                  }
      
                  if (r == null)
                  {
                      return;
                  }
                  if (!Suggestions.Contains(r))
                  {
                      if (Suggestions.Count >= MaxSuggestionsCount)
                      {
                          Suggestions.RemoveAt(MaxSuggestionsCount - 1);
                      }
                      Suggestions.Insert(0, r);
                  }
                  else
                  {
                      Suggestions.Remove(r);
                      Suggestions.Insert(0, r);
                  }
                  Suggestions_clone = Suggestions;
                  NotifyDataSetChanged();
              }
      
              public void SetSuggestions(List<S> suggestions)
              {
                  Suggestions = suggestions;
                  Suggestions_clone = suggestions;
                  NotifyDataSetChanged();
              }
      
              public void ClearSuggestions()
              {
                  Suggestions.Clear();
                  Suggestions_clone = Suggestions;
                  NotifyDataSetChanged();
              }
      
              public void DeleteSuggestion(int position, S r)
              {
                  if (r == null)
                  {
                      return;
                  }
                  //delete item with animation
                  if (Suggestions.Contains(r))
                  {
                      NotifyItemRemoved(position);
                      Suggestions.Remove(r);
                      Suggestions_clone = Suggestions;
                  }
              }
      
              public List<S> GetSuggestions()
              {
                  return Suggestions;
              }
      
              public int GetMaxSuggestionsCount()
              {
                  return MaxSuggestionsCount;
              }
      
              public void SetMaxSuggestionsCount(int maxSuggestionsCount)
              {
                  MaxSuggestionsCount = maxSuggestionsCount;
              }
      
              protected LayoutInflater GetLayoutInflater()
              {
                  return Inflater;
              }
      
              public SuggestionsAdapter(LayoutInflater inflater)
              {
                  Inflater = inflater;
              }
      
              public abstract int GetSingleViewHeight();
      
              public int GetListHeight()
              {
                  return ItemCount * GetSingleViewHeight();
              }
      
              public abstract void OnBindSuggestionHolder(S suggestion, RecyclerView.ViewHolder holder, int position);
      
              public override int ItemCount => Suggestions.Count;
      
              public Filter Filter => null;
      
              public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
              {
                  OnBindSuggestionHolder(Suggestions[position], holder, position);
              }
      
              public interface IOnItemViewClickListener
              {
                  void OnItemClickListener(int position, View v);
                  void OnItemDeleteListener(int position, View v);
              }
          }
      }
      
    6. Build your project again and that’s all! Your library is fully working.

    If you want to check the result.

    • Marked as answer by

      Thursday, June 3, 2021 12:00 AM

—— Построение начато: проект: Склад фирмы, Конфигурация: Debug x86 ——
F:дипломСклад фирмыСклад фирмыProgram.cs(18,33): ошибка CS0246: Не удалось найти имя типа или пространства имен «Form1» (пропущена директива using или ссылка на сборку?)

Компиляция завершена — ошибок: 1, предупреждений: 0

Кликните здесь для просмотра всего текста

Построение начато 17.06.2016 1:40:51.
ResolveAssemblyReferences:
Будет создан список исключений профиля TargetFramework.
CoreResGen:
Для всех выходных данных обновления не требуется.
GenerateTargetFrameworkMonikerAttribute:
Целевой объект «GenerateTargetFrameworkMonikerAttribute» пропускается, так как все выходные файлы актуальны по отношению к входным.
CoreCompile:
C:WindowsMicrosoft.NETFrameworkv4.0.30319Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreportrompt /warn:4 /defineEBUG;TRACE /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientMicrosoft.CShar p.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientmscorlib.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Core.dll » /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Data.Dat aSetExtensions.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Data.dll » /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Deployme nt.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Drawing. dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Windows. Forms.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Xml.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Xml.Linq .dll» /debug+ /debug:full /filealign:512 /optimize- /out:»objx86DebugСклад фирмы.exe» /resource:»objx86DebugСклад.склад.resources» /resource:»objx86DebugСклад.Form2.resources» /resource:»objx86DebugСклад.Form3.resources» /resource:»objx86DebugСклад.Form4.resources» /resource:»objx86DebugСклад.Properties.Resources.resources» /target:winexe Component1.cs Component1.Designer.cs Form1.cs Form1.Designer.cs Form2.cs Form2.Designer.cs Form3.cs Form3.Designer.cs Form4.cs Form4.Designer.cs Program.cs PropertiesAssemblyInfo.cs «Покупатели.cs» «Поставщики.cs» «Склад_фирмыDataSet.Designer.cs» «Товар.cs» PropertiesResources.Designer.cs PropertiesSettings.Designer.cs «C:UsersКрисAppDataLocalTemp.NETFramework,Version=v4.0,Profile=Client.Asse mblyAttributes.cs»

СБОЙ построения.

Затраченное время: 00:00:01.10
========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========
Теперь пишет вот такую ошибку

Добавлено через 12 минут
—— Построение начато: проект: Склад фирмы, Конфигурация: Debug x86 ——
F:дипломСклад фирмыСклад фирмыForm1.Designer.cs(3,19): ошибка CS0060: Несовместимость по доступности: доступность базового класса «Склад.Form1» ниже доступности класса «Склад.склад»
F:дипломСклад фирмыСклад фирмыForm1.cs(13,26): (Связанное местоположение)
F:дипломСклад фирмыСклад фирмыForm1_2.cs(8,11): (Связанное местоположение)

Компиляция завершена — ошибок: 1, предупреждений: 0
Построение начато 17.06.2016 1:52:22.

Кликните здесь для просмотра всего текста

ResolveAssemblyReferences:
Будет создан список исключений профиля TargetFramework.
CoreResGen:
Для всех выходных данных обновления не требуется.
GenerateTargetFrameworkMonikerAttribute:
Целевой объект «GenerateTargetFrameworkMonikerAttribute» пропускается, так как все выходные файлы актуальны по отношению к входным.
CoreCompile:
C:WindowsMicrosoft.NETFrameworkv4.0.30319Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreportrompt /warn:4 /defineEBUG;TRACE /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientMicrosoft.CShar p.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientmscorlib.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Core.dll » /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Data.Dat aSetExtensions.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Data.dll » /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Deployme nt.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Drawing. dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Windows. Forms.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Xml.dll» /reference:»C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientSystem.Xml.Linq .dll» /debug+ /debug:full /filealign:512 /optimize- /out:»objx86DebugСклад фирмы.exe» /resource:»objx86DebugСклад.склад.resources» /resource:»objx86DebugСклад.Form2.resources» /resource:»objx86DebugСклад.Form3.resources» /resource:»objx86DebugСклад.Form4.resources» /resource:»objx86DebugСклад.Properties.Resources.resources» /target:winexe Component1.cs Component1.Designer.cs Form1.cs Form1.Designer.cs Form1_2.cs Form2.cs Form2.Designer.cs Form3.cs Form3.Designer.cs Form4.cs Form4.Designer.cs Program.cs PropertiesAssemblyInfo.cs «Покупатели.cs» «Поставщики.cs» «Склад_фирмыDataSet.Designer.cs» «Товар.cs» PropertiesResources.Designer.cs PropertiesSettings.Designer.cs «C:UsersКрисAppDataLocalTemp.NETFramework,Version=v4.0,Profile=Client.Asse mblyAttributes.cs»

СБОЙ построения.

Затраченное время: 00:00:00.58
========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========
Стало выдавать такую ошибку после перезагрузки. Вообще не понимаю что происходит

I tried to compile this code but it won’t work, getting this error upon compilation:

PongForm1.Designer.cs(14,33,14,40): error CS0115: ‘Pong.Form1.Dispose(bool)’: no suitable method found to override

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace Pong
{
    public partial class gameArea : Form
    {
        PictureBox picBoxPlayer, picBoxAI, picBoxBall;
        Timer gameTime; // also the game loop

        const int SCREEN_WIDTH = 800;
        const int SCREEN_HEIGHT = 600;

        Size sizePlayer = new Size(25, 100);
        Size sizeAI = new Size(25, 100);
        Size sizeBall = new Size(20, 20);

        const int gameTimeInterval = 1;

        const int ballStartSpeed = 2;
        const int ballIncreaseSpeedRate = 1;
        const int ballSpeedLimited = 15;

        const int aiOffSetLoops = 15;

        int ballSpeedX = ballStartSpeed;
        int ballSpeedY = ballStartSpeed;


        Random rad;
        int aiOffSet;
        int aiOffSetCounter;

        Dictionary<string, SoundPlayer> sounds;

        public gameArea()
        {
            InitializeComponent();

            this.DoubleBuffered = true;

            picBoxPlayer = new PictureBox();
            picBoxAI = new PictureBox();
            picBoxBall = new PictureBox();

            gameTime = new Timer();
            gameTime.Interval = gameTimeInterval;

            gameTime.Tick += new EventHandler(gameTime_Tick);

            this.Width = SCREEN_WIDTH;
            this.Height = SCREEN_HEIGHT;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.BackColor = Color.Black;

            picBoxPlayer.Size = sizePlayer;
            picBoxPlayer.Location = new Point(picBoxPlayer.Width / 2, ClientSize.Height / 2 - picBoxPlayer.Height / 2);
            picBoxPlayer.BackColor = Color.Blue;
            this.Controls.Add(picBoxPlayer);

            picBoxAI.Size = sizeAI;
            picBoxAI.Location = new Point(ClientSize.Width - (picBoxAI.Width + picBoxAI.Width / 2), ClientSize.Height / 2 - picBoxPlayer.Height / 2); // TODO: why picBoxPlayer and not picBoxAI?
            picBoxAI.BackColor = Color.Red;
            this.Controls.Add(picBoxAI);

            rad = new Random();
            aiOffSet = 0;
            aiOffSetCounter = 1;

            picBoxBall.Size = sizeBall;
            picBoxBall.Location = new Point(ClientSize.Width / 2 - picBoxBall.Width / 2, ClientSize.Height / 2 - picBoxBall.Height / 2);
            picBoxBall.BackColor = Color.Green;
            this.Controls.Add(picBoxBall);

            // Load Sounds
            sounds = new Dictionary<string, SoundPlayer>();
            for (int k = 1; k <= 10; k++)
            {
                sounds.Add(String.Format(@"pong{0}", k), new SoundPlayer(String.Format(@"pong{0}.wav", k)));
            }

            // Start Game loop
            gameTime.Enabled = true;
        }

        void gameTime_Tick(object sender, EventArgs e)
        {
            picBoxBall.Location = new Point(picBoxBall.Location.X + ballSpeedX, picBoxBall.Location.Y + ballSpeedY);
            gameAreaCollosions();
            padlleCollision();
            playerMovement();
            aiMovement();
        }

        private void iaChangeOffSet()
        {
            if (aiOffSetCounter >= aiOffSetLoops)
            {
                aiOffSet = rad.Next(1, picBoxAI.Height + picBoxBall.Height);
                aiOffSetCounter = 1;
            }
            else
            {
                aiOffSetCounter++;
            }
        }

        private void gameAreaCollosions()
        {
            if (picBoxBall.Location.Y > ClientSize.Height - picBoxBall.Height || picBoxBall.Location.Y < 0)
            {
                iaChangeOffSet();
                ballSpeedY = -ballSpeedY;
                sideCollision();
            }
            else if (picBoxBall.Location.X > ClientSize.Width)
            {
                padlleSideCollision();
                resetBall();
            }
            else if (picBoxBall.Location.X < 0)
            {
                padlleSideCollision();
                resetBall();
            }
        }
        private void resetBall()
        {
            if (ballSpeedX > 0)
                ballSpeedX = -ballStartSpeed;
            else
                ballSpeedX = ballStartSpeed;
            if (ballSpeedY > 0)
                ballSpeedY = -ballStartSpeed;
            else
                ballSpeedY = ballStartSpeed;

            aiOffSet = 0;
            picBoxBall.Location = new Point(ClientSize.Width / 2 - picBoxBall.Width / 2, ClientSize.Height / 2 - picBoxBall.Height / 2);
        }
        private void playerMovement()
        {
            if (this.PointToClient(MousePosition).Y >= picBoxPlayer.Height / 2 && this.PointToClient(MousePosition).Y <= ClientSize.Height - picBoxPlayer.Height / 2)
            {
                int playerX = picBoxPlayer.Width / 2;
                int playerY = this.PointToClient(MousePosition).Y - picBoxPlayer.Height / 2;

                picBoxPlayer.Location = new Point(playerX, playerY);
            }
        }
        private void aiMovement()
        {
            int aiX = ClientSize.Width - (picBoxAI.Width + picBoxAI.Width / 2);
            int aiY = (picBoxBall.Location.Y - picBoxAI.Height / 2) + aiOffSet;

            if (aiY < 0)
                aiY = 0;
            if (aiY > ClientSize.Height - picBoxAI.Height)
                aiY = ClientSize.Height - picBoxAI.Height;

            picBoxAI.Location = new Point(aiX, aiY);
        }
        private void padlleCollision()
        {
            if (picBoxBall.Bounds.IntersectsWith(picBoxAI.Bounds))
            {
                picBoxBall.Location = new Point(picBoxAI.Location.X - picBoxBall.Width, picBoxBall.Location.Y);
                ballSpeedX = -ballSpeedX;
                aiCollision();
            }
            if (picBoxBall.Bounds.IntersectsWith(picBoxPlayer.Bounds))
            {
                picBoxBall.Location = new Point(picBoxPlayer.Location.X + picBoxPlayer.Width, picBoxBall.Location.Y);
                ballSpeedX = -ballSpeedX;
                playerCollision();
            }
        }
        private void playerCollision()
        {
            sounds["pong1"].Play();
            SlowDownBall();
        }
        private void aiCollision()
        {
            sounds["pong2"].Play();
            SlowDownBall();
        }
        private void sideCollision()
        {
            sounds["pong3"].Play();

            SpeedUpBall();
        }
        private void padlleSideCollision()
        {
            sounds["pong9"].Play();
        }
        private void SpeedUpBall()
        {
            if (ballSpeedY > 0)
            {
                ballSpeedY += ballIncreaseSpeedRate;
                if (ballSpeedY >= ballSpeedLimited)
                    ballSpeedY = ballSpeedLimited;
            }
            else
            {
                ballSpeedY -= ballIncreaseSpeedRate;
                if (ballSpeedY <= -ballSpeedLimited)
                    ballSpeedY = -ballSpeedLimited;
            }

            if (ballSpeedX > 0)
            {
                ballSpeedX += ballIncreaseSpeedRate;
                if (ballSpeedX >= ballSpeedLimited)
                    ballSpeedX = ballSpeedLimited;
            }
            else
            {
                ballSpeedX -= ballIncreaseSpeedRate;
                if (ballSpeedX <= -ballSpeedLimited)
                    ballSpeedX = -ballSpeedLimited;
            }
        }
        private void SlowDownBall()
        {
            if (ballSpeedY > 0)
            {
                ballSpeedY -= ballIncreaseSpeedRate;
                if (ballSpeedY <= ballStartSpeed)
                    ballSpeedY = ballStartSpeed;
            }
            else
            {
                ballSpeedY += ballIncreaseSpeedRate;
                if (ballSpeedY >= -ballStartSpeed)
                    ballSpeedY = -ballStartSpeed;
            }

            if (ballSpeedX > 0)
            {
                ballSpeedX -= ballIncreaseSpeedRate;
                if (ballSpeedX <= ballStartSpeed)
                    ballSpeedX = ballStartSpeed;
            }
            else
            {
                ballSpeedX += ballIncreaseSpeedRate;
                if (ballSpeedX >= -ballStartSpeed)
                    ballSpeedX = -ballStartSpeed;
            }
        }
    }
}

User-1728618280 posted

Hi there

 I am having some compilation error and i dont understand where my code is wrong. The error is in a compilation file
Line 618:        public override int GetTypeHashCode() {.

Any help please. Here is my code, i am trying to add data from two dropdownlist with different datasource to another table called Group event. The dropdownlists represent a selection of an event and a group.

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial
class
GroupEvent : System.Web.UI.Page


{

public
string connStr;

public
string sql3;

//add an event to a group by using the AddGroupEvent method


protected
void AddGroupEvent(object sender,
EventArgs e)

{

//build connection object


SqlConnection conn;

conn = new
SqlConnection();


connStr +=
«data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Sussex.mdf;User Instance=true»;

conn.ConnectionString = connStr;

sql3 = «insert into tbl_GroupEvent (Group_id, Event_id) values( «;

sql3 += «‘» + listgroup.SelectedItem +
«‘»;


sql3 +=
«‘» + listevent.SelectedItem +
«‘)»;

lbltest.Text = sql3;

SqlCommand dbCommand =
new
SqlCommand();

dbCommand.CommandText = sql3;

dbCommand.Connection = conn;

conn.Open();

dbCommand.ExecuteNonQuery();

conn.Close();

}

}

Понравилась статья? Поделить с друзьями:
  • Ошибка компилятора cs0030
  • Ошибка компиляции для платы generic esp8266 module
  • Ошибка компилятора cs0029
  • Ошибка компиляции для платы esp32 wrover module
  • Ошибка компилятора cs0021