ADO.NET :: Cannot Implicitly Convert IDbConnection Con = New SqlConnection
Jan 17, 2011
so i have the function below in a webservice. and it works, but when i try to copy it to aspx page code behind, i get the message in the subject. Can someone tell me if the function below is valid? One of my project uses it and it works.
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string>' to 'string' OK I am fairly new to LINQ, but I am starting to get the hang of it. So here is the of my code that bugs:
[Code]....
And it returns this error, on the second line for p:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string>' to 'string'
I want to log all errors happened in my App to sql db. I'm passing all exception properties like (ex.Message, ex.Source, ex.StackTrace, ex.TargetSite and ex.InnerException) to stored procedure.
The problem is that when I try to pass the ex.InnerException as string to stored procedure I got this error:
Cannot implicitly convert type 'System.Exception' to 'string'
I tried ex.InnerException.ToString() and Convert.ToString (ex.InnerException) but no success.
I'm having a problem with reading a string from sqlserver database and use it as the text of a label,
getDescTableAdapter gd = new getDescTableAdapter(); Label2.Text = Convert.ToString(gd.GetDesc(pid));
what i get in the form is: getDesc ! everything is right in the dataset and if i bind it to a gridview it works fine but when i convert it to string it seems it converts the table adaptor's name instead of the value.ance
If I have below code, how to make it work as it has below compile error:
Error: cannot implicitly convert type 'System.Linq.Iqueryable<system.data.DataSet> to 'System.Data.Dateset'. An explicit conversion exists.
public DataSet GetProductList() { using (var sdatabase = new DatabaseDataContext()) { IQueryable<DataSet> result = wmsdatabase.ExecuteQuery<DataSet>(@"SELECT productid, productname from product group by productid, productname").AsQueryable(); return result; // Compile error here } }
I have a datalist which querys the database and pulls the data ApplicantID, date, and testimonial into the datalist. I now want to get the username from the ApplicantID. Im using TLists to do this but on the line ApplicantDetails = JustClick.DAL.DataRepository.ApplicantProvider.GetByApplicantID(ApplicantID);
im getting the error cannot implicitly convert type on datalist can anyone help as to why and how I can fix this cheers. The code im using is below
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'hcgames.ObjectClasses.ShoppingCart.ShoppingCartCartAddon'. An explicit conversion exists (are you missing a cast?)
From this query
ShoppingCartItems items = Cart.GetAllItems(); ShoppingCartCartAddons addons = Cart.GetAllAddons(); var stuff = from x in items select new ShoppingCartItem() { ProductID = x.ProductID, Quantity = x.Quantity, Name = x.Name, Price = x.Price, Weight = x.Weight, Addons = (from y in addons where y.ShoppingCartItemID == x.ID select y) };
I have this method which does not build, it errors with the message:
Cannot implicitly convert type 'System.Web.HttpPostedFile' to 'System.Web.HttpPostedFileBase' I really need this to be of type HttpPostedFileBase instead of HttpPostedFile, I have tried boxing and it does not work: foreach (string inputTagName in HttpContext.Current.Request.Files) { HttpPostedFileBase filebase =HttpContext.Current.Request.Files[inputTagName]; if (filebase.ContentLength > 0) { if (filebase.ContentType.Contains("image/")) { SaveNonAutoExtractedThumbnails(doc, filebase); } } }
In Visual Studio 2008 I have a Class Library project (called Media) to which I added a Web Reference (not a Service Reference) to a third-party web service (wsdl). In the Class Library project a proxy class is created for using the service along with several classes for the types used in that service.
I also have a second Class Library (called Sync) that references the first one. And then I have a Web Site project that references the second class library. All of this is .NET 3.5
So Web Site > Class Library (Sync) > Class Library with web service reference (Media)
I want to step into the generated code, so I fire up the web site in IIS 7.5 and trigger the call to a method in the second class library (Sync) that in turn should call the web service proxy. I was fully expecting to hit the breakpoint, but instead got an exception:
Unable to generate a temporary class(result=1). error CS0029: Cannotimplicitly convert type Media.WebService.multiValuedAttribute to Media.WebService.multiValuedAttribute[]
Why is ASP.NET trying to generate a temporary class? Don't I already have the generated class from the first Class Library (Media)?
i would like to know if there's something wrong in this asp.net code:
mydatareader = mycmd.executeReader() if myDataReader.HasRow then // Do something end if myConnection.Close()
If i avoid to call a "MyDataReader.Close()" does the connection close anyway ? I ask this because i'm assuming that if call a "MyConn.Close" it automatically close the associated datareader... or am i wrong ?
I got any error from the code, saying 'not all code path return a value', i suspect it is the catch block doesnt return a value. If so, what value should i return?
i have 5 methods in classA. each and every methods i have open the sqlconnection and close it, instead of that is there anyway to create a sqlconnection at one time if its opened then no need to create a new connection, if its closed then we have to connect.