简体   繁体   中英

the call is ambiguous between the same methods Asp.Net C#

I tried to edit a GridView in one of the pages of my site, topics.aspx. I decided to change the DataSourceID, from the one I put in design view on the grid view, with a custom one, following this tutorial

http://www.c-sharpcorner.com/uploadfile/9f0ae2/gridview-edit-delete-and-update-in-asp-net/?authorFollow=true-9f0ae2-article&name=neha-sharma52

I COPIED and PASTED the exact SqlConnection from the register.aspx.cs page, which is

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

as a private field in topic.aspx.cs.

Suddenly, my register page doesn't work anymore. The "SqlConnection" in

new SqlConnection(...)

call is "ambigous" between

SqlConnection.SqlConnection(string)

and

SqlConnection.SqlConnection(string)

I undid everything I did, obviously. My last resort is to delete topics.aspx and topics.aspx.cs altogether, but... will it work then? I highly doubt did.

I don't know what i did wrong, I only copied and pasted a line of code, and suddenly, my register.aspx and login.aspx don't work anymore. What is the problem?

EDIT: The imports I am using are

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

如果您的连接字符串未使用Integrated Security = true ,则可以尝试SqlConnection(String,SqlCredential)或仅调用默认构造函数

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM