我一直坚持这个:
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Supplier;
{
public partial class Supplier : Form
{
public Supplier()
{
InitializeComponent();
}
public object ConfigurationManager { get; private set; }
private void button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
string command = "insert into Supplier (SupplierID, SupplierName, Address, City, Country, ContactName, Position, Product) values (@SupplierID, @SupplierName, @Address, @City, @Country, @ContactName, @Position, @Product)";
SqlCommand com = new SqlCommand(command, con);
com.CommandType = CommandType.Text;
我收到错误:
'object'不包含'ConnectionStrings'的定义,并且没有扩展方法'ConnectionStrings'接受类型'object'的第一个参数可以找到......
就行了
ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
答案 0 :(得分:4)
您需要添加对public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
UIViewController yourViewController = UIStoryboard.FromName("yourStoryboard",NSBundle.MainBundle).InstantiateViewController("yourViewController_StoryboardID");
this.Window = new UIWindow(UIScreen.MainScreen.Bounds);
UINavigationController navigationController = new UINavigationController(yourViewController);
this.Window.RootViewController = navigationController;
this.Window.MakeKeyAndVisible();
return true;
}
的引用,并在“使用”部分中添加System.Configuration.dll
答案 1 :(得分:0)
谢谢大家! 我删除了该对象,添加了使用System.Configuration,并在References选项卡中添加了对System.Configuration的引用。 它奏效了!