Without having to use logic to do this, I would like to store the names of Classes as Strings in one of my Database tables. When I retrieve the String from the table, I would like to some how use the string to make reference to the Class?
For example.
I store "Class1" as a string in my table.
I retrieve "Class1" as a string from my table.
I (somehow) convert the string "Class1" so it is usable in such an instance as...
I am sitting with a situation where i have a Method that that i want to put into a Class because i am calling it from various forms.
The method in this case loads a dropdown list. Currently i am stuck where i have to load the list into the DropDown Control on the form. I dont seem to get the control on the form. So far my code looks something like this This does not seem to work. I keep getting this error...
Error 3 Argument '1': cannot convert from 'string' to 'int'
on VWD 2005 this code works fine, but on 2008 it says I haven't created an instance of the object. I want to convert the object connString (a connection string) into a string.
'This acceses the virtual directory web.config file for connection strings 'We have to convert the object to a connection string Dim rootWebConfig As System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/VirtualDirec") Dim connString As System.Configuration.ConnectionStringSettings connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ConnectString1") Dim strConnString As String = connString.ToString().......
I have project in development where string operations like "Hi " + variable + ", welcome to Project" are used at many places (given example is very minor one).
One of the requirement is to convert it to string.format style.
It is very long and tedious job, where I would not like to break earlier working code due to any human error might happen while converting it.
I would like to if any Macro or VS command which I can create to handle it. Just like we mark block of code and do Extract function in Re-factor options.
I have a string I need to convert back to a date. I can call .ToString("yyyyMMdd") and get the string i want. My question is how can I convert that back into a date? I'm trying something like the following with no luck.
DateTime d; var formatInfo = new DateTimeFormatInfo {ShortDatePattern = "yyyyMMdd"}; if (DateTime.TryParse(details.DetectionTime.Date, formatInfo, DateTimeStyles.None, out d)) { lit.Text = d.ToShortTimeString(); //would like 07/30/2010 as the text }
I've never used DateTimeFormatInfo before if that isn't obvious. Can someone point me in the right direction. I know I could probably use substring and create a new DateTime(y, m, d) etc... I'm just wondering since c# interpreted .ToString() correctly, if it can't derive a date from the very same string it output.
I have a Solution that has two class libraries. I'm trying to convert the whole solution from asp.net 3.5 to 4.
Right now the libraries are in my Visual Studio 2008 projects folder. I've installed VS 2010. Should I just copy the libraries from the 2008 project folder to my 2010 project folder and open them in VS 2010?
What is the best practices for this? The entire solution is in a single folder in my VS 2008 Project folder, and each application and class library is in their own subfolder.
I need to convert .NET data to XML types and viceversa and I wonder if there is any class already on the .NET framework to do it. UPDATE I want to perform a data type conversion.
i am displaying some news from rss feeds in the page. But i am stuck up in the date time conversion. I got th published datetime as pdt formated string. How can i convert to my local time. Coversion from the pdt string tot DateTime is error..
[Code]....
This second line is error and i need the result in the specified format or same format as in the published date but in local time ie IST (India Standard Time)
i want to check only if the column Active is Yes, then get into the if loop. But it gives me an error "Cannot convert from string to int" for the last condition in if. What do you guys i can do.
if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns[0].ColumnName["Status"] == "Y") { disableloc.DataSource = ds; disableloc.DataBind(); } else { ds = null; disableloc.DataSource = ds; disableloc.DataBind(); The stored procedure is SELECT ML.locationname, rtrim(ML.address) + (CASE WHEN ML.Address2 IS NOT NULL THEN ('' '' + rtrim(ML.Address2)) ELSE '''' END) + '' - ''+ ML.city + '', ''+ ML.state as address, ML.locationid, ML.merchantid, case when ML.active <> ''Y'' then ''Deactive'' else ''Active'' end [Status], (SELECT count(*) as retval FROM merchant_statistics WHERE type = ''merchant'' AND locationID= ML.LocationID AND status = ''clicked'') as stat, '' '' as button,'' '' as blank , dbo.GetCouponCountForLocations(@_merchantid,ML.locationID) couponCount, MP.DomainName, (SELECT Count(*) FROM Promotion WHERE LocationId = ML.locationid AND PostType = 1) AS jobs FROM merchant_location ML , Merchant_Pages MP WHERE MP.LocationID = ML.LocationID AND ML.merchantid = @_merchantid Order By '
i have string like "30/03/2010 12:03:15:PM" i want to covert in date time how it possible?to convert i got this error "String was not recognized as a valid DateTime."
In timsplit i have value "17:00 - 2:00".Then i am converting it TimeIn and TimeOut.TimeIn is string now and how to convert it to int32.I am getting error while convertin Timesplit = strResultData.Split('-'); string TimeIn = Timesplit[0]; string TimeOut = Timesplit[1]; int TimeI = Int32.Parse(TimeIn);
I am trying to convert a field from a string to an int, then pass it to a query using tableadapters. I have the following function:
protected String countResponses(String value) { String input = value.ToString(); int fordb = Int32.Parse(input); FrontendTableAdapters.ForumTableAdapter ta = new FrontendTableAdapters.ForumTableAdapter(); DataTable table = ta.CountPosts(value); if (table.Rows.Count > 0) { return table.Rows[0].ItemArray[1].ToString(); } else { return "Unknown"; } }
It is working greate up to putting it in CountPosts() where I get the following error: Error 4Cannot implicitly convert type 'object' to 'System.Data.DataTable'. An explicit conversion exists (are you missing a cast?) :UsersDaveDesktopWebAppsFigmentvilleFigmentvilleyoursayDefault.aspx.cs 49 31 I think this is because it is looking for an int. But haven't I already converted it to an int?