w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » C# » Page 4
Fetch row and Save in Variable
I sort it out myself SqlCommand cmd = new SqlCommand("SELECT * FROM users WHERE (username = '" + uname + "') AND (password = '" + pass + "');", conn); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); SqlDataReader dr = cmd.ExecuteReader(); Here it is guys, i hope it help noobs. You can fetch it with dr.Read()

Categories : C#

error in insert data to access database
Try to change the Mobile Phone number data type to string in your function and to varchar(10) in your database. It is not good idea to set it as numerical variable. Then try to remove "" from your Id column, while data entry. After doing these steps, it may work fine

Categories : C#

Upload File from jQuery AJAX POST
If you're already sending it successfully in PHP, you can get access to the same variable in C# by referring to the HttpContext.Current.Request.Files variable. HttpContext.Current.Request.Files["postedFileName"] will give you access to a HttpPostedFile object, which allows you to access the InputStream, FileName, ContentType, and other properties.

Categories : C#

how can i access the checked status of each checkbox in a datagridview control in c#?
You can use the CellContentClick-event but you have to check if it's the right cell: private void DataGridView_CellContentClick(Object sender, DataGridViewCellEventArgs e) { DataGridView grid = (DataGridView)sender; var chkCell = grid[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell; if (chkCell != null) { bool checked = (bool)chkCell.EditedFormattedValue; /

Categories : C#

List of List of struct not serializing. System.RuntimeType is inaccessible due to its protection level. Only public types can be processed
It's probably the public Type Type { get; set; } field, holding a reference to a RuntimeType instance which causes the error. RuntimeType is not serializable, that is what the error message tells you.

Categories : C#

How to change the colour of an MVC webgrid row text depending on some condition
Try to put this right under your @grid.Html() @Scripts.Render("~/bundles/jquery") <script type="text/javascript"> $('tr').each(function (index) { //iterate over all table rows if (index > 0) { //skip header if ($(this).children('td:nth-child(3)').text() < 31) //look for the 3rd td in each row. thats where your age is. { $(this)

Categories : C#

How to sync only certain rows in a database
Could you maybe use a SQL function for the filter-parameter so this can change? Something like serverTemplate.Tables["tableA"].AddFilterColumn("ModuleId"); serverTemplate.Tables["tableA"].FilterClause = "[side].[ModuleId] = sf_GetCurrentModule()"; You could create a SQL function sf_GetCurrentModule() to return the ModuleId to be synched. If the rows to be synched vary from client to client, yo

Categories : C#

Switch-case of EventArg types
In switch case block each case must be evaluated statically. This means that you need a constant in each case. This post maybe useful also C# switch statement limitations - why?

Categories : C#

Cumulative sum of stock movements when dates and id is not in the same order
Your problem is that your Date field does not have enough granularity to properly order on that field. what happens here is that, if you sort a field, by default it maintains the order before the sort when there are conflicts. You're already trying to mitigate this with (stockMovement1.ShippingBill.Date == stockMovement2.ShippingBill.Date ? stockMovement1.ShippingBill.Date >= stockMovemen

Categories : C#

The call stack never gives the location of the error
Use the Exceptions dialog, set the debugger to Break on User-Unhandled Exceptions. In Visual Studio's menu, Open Debug -> select Exceptions... -> check the first Checkbox for the Command Language Runtime Exceptions. Edit: just notice that you are using Express version of 2012. As per the link, To enable the Exceptions menu in Express versions, on the Tools menu, click Settings, and then se

Categories : C#

C# - TextBox_TextChanged event - revert to previous value
What i would do(not sure if it is the best option) is to make a variable and set its value at the end of your TextChanged. that way, the next time it will enter the TextChanged, you will still have the value of your previous change. string txt = ""; private void txtFCServerURL_TextChanged(object sender, EventArgs e) { if(txtFCServerURL.Text != txt) {

Categories : C#

TreeViewItem toggle doesn't work with custom style
When you add Border, which becomes root element of your template, you need to move VisualStateGroups from Grid to that Border (top level element of your ControlTemplate) <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"> <!-- other setters --> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Ty

Categories : C#

Saving .NET user settings takes very long time
First suggestion: The calls to retrieve paper sources and paper sizes are being passed through to the driver. Your best bet is going to make sure that the newest version of the driver is installed. It's possible that older versions of the driver (in particular, those from the CD that came in the box) are old and buggy. If you haven't already, hit the manufacture's website, and grab the latest. S

Categories : C#

Code-First Migrations for multiple databases?
You are trying to use a connectionString designed to work with Database First / Model First. You can tell because your providerName is System.Data.EntityClient instead of System.Data.SqlClient. Your connection string should look like this: <connectionStrings> <add name="MyContext" connectionString="Data Source=SQLSERVERDB; Initial Catalog=TestDB_CodeFirst;user id=***;passw

Categories : C#

WPF formatting by Class instead of property?
You may bind color property to instance and write a converter which will return different Brush for different type: Background={Binding Converter={c:InstanceToColorConverter}}, in InstanceToColorConverter's Convert method if statements cascade may be implemented if(value is A)return new SomeBrush();else if(value is B)return new AntoherBrush(); You may also create class Attribute which s

Categories : C#

Type alias on right side of using alias directive
I suppose this restriction is simply to rule out having to worry about situations like the following in the compiler. using X = C<Y>; using Y = C<X>; class C<T> { } Of course the problem is that X is C<Y> is C<C<X>> is C<C<C<Y>>> is ... If the language restriction was looser, disallowing only circular using alias directives, the compiler co

Categories : C#

Generic class inherit from Dictionary with Collection
You can do this class CollectionDictionary<K, C> : Dictionary<K, ICollection<C>> It removes the constraint you had that makes the ICollection have an empty constructor. In order to be able to create new collections you could ask for a delegate that does that. But in your case I think your original solution would produce less boilerplate code. // ctor public CollectionDiction

Categories : C#

regenerateExpiredSessionId for cookieless="UseCookies"
If you use session with cookies enabled asp.net does not allocate memory for session data until a session object is created. Because of this a new session id will be generated for each page request. In this case you can create a session instance inside Session_start event of Global.asax file. Please refer the following link for further information, http://msdn.microsoft.com/en-us/library/system.

Categories : C#

c# object float field is different than database object float field
If you have literally used a SQL float with a C# float, these are not comparable. You should be using a SQL real to store your C# float. See here for full chart: C# Equivalent of SQL Server DataTypes As an aside, you will always have the potential for these issues when working with floating point numbers. Where possible, use a decimal instead. Further reference for SQL float != C# float: Why

Categories : C#

set or get Child Component properties inside Window.Resources
In your scenario, you are not sharing the class "Dialog" by using partial class definition. To look inside the FramworkElement's children, you can use this. public async void button_Click(object sender, RoutedEventArgs e) { dialog = (CustomDialog)this.Resources["CustomDialogTest"]; // at this point ensure that "lbTitle" is instantiated and part of the dialogs visual tree var tb = dia

Categories : C#

How to get values from XML?
This should give you all node11 values. It is assuming that you want ALL node11 values var OrganizationCodes = XDocument.Parse(serviceXML) .Descendants("node11") .Select(x => x.Value);

Categories : C#

WPF validation (BindingGroup).item[0] return null
Because (value as BindingGroup).Items[0] is of the type 'DataRowView', it has nothing to do with your tblTesting class. You can get the value of the first cell that corresponds to the NO property. var dataRowView = (value as BindingGroup).Items[0] as DataRowView; int no = Convert.ToInt32(dataRowView.Row[0]); if (no > 10) //do the rest...

Categories : C#

Entity Framework 6 could not create a foreign key
Taken from the vanilla instructions, is there a reason why you can't use the .PrimaryKey(t => t.Id) as part of the main CreateTable method?

Categories : C#

Suggest a way in threading that always fixed number of threads must be used in computing?
Within a static counter, you might be able to get the number of current threads. Every time you call start a task there is the possibility to use the Task.ContinueWith (http://msdn.microsoft.com/en-us/library/dd270696.aspx) to notify that it's over and you can start another one. This way there is going to be always 8 tasks running.

Categories : C#

MSOCAF Verification - Move P/Invokes to NativeMethods class
The real problem appears to be error 4. It states an incompatibility between: OfficeOpenXml.Utils.CompoundDocument.ILockBytes and OfficeOpenXml.Utils.ILockBytes So clearly one of these types was used to declare CreateILockBytesOnHGlobal, and a different type was used to declare the variable that you pass when calling CreateILockBytesOnHGlobal. You need to decide which of these two types to

Categories : C#

Column layout of RDLC Report
Your requirement calls for Matrix report. The idea is that your date values will be placed in the header of dynamic columns and projects into row headers. Here is the explanation.

Categories : C#

Programmatically format a cell as a checkbox
This is an example using cell B9 It is implemented using Double-click rather than Single-click Enter the following event macro in the worksheet code area: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim B9 As Range Set B9 = Range("B9") If Intersect(B9, Target) Is Nothing Then Exit Sub B9.Font.Name = "Marlett" Cancel = True If B9.Valu

Categories : C#

Swipe gestures in Windows Phone 8.1
OnManipulationCompleted is probably a method provided by your base class its signature does not match. I suspect that you need to change the name to avoid a conflict such as: mainGrid.ManipulationCompleted += MainGridManipulationCompleted; public void MainGridManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { var velocities = e.Velocities; }

Categories : C#

How to ignore "ease of access" settings on Windows Phone?
It's a common bug in apps that they ignore the high contrast settings and hardcode their own colours. So yes: you can do this by doing the wrong thing and hardcoding your settings instead of using the system resources. You can override most system brushes in your app resources in app.xaml and you can hardcode colours in your Xaml and control styles. That said, please use this for good not evil.

Categories : C#

itextsharp, issue with PDFtable constructor
The class you need is PdfPTable, not PdfTable (mind the extra P). Please let me know if you have found a tutorial where it says: PdfTable table = new PdfTable(5); I will personally contact the author trying to convince him to stop publishing non sense ;-) PdfTable used to be a class in a very old version of iTextSharp (a version that should no longer be used). It was an internal helper class f

Categories : C#

How to reverse a string that contains Hebrew letters and numbers?
public static string Reverse(string t) { char[] charArray = t.ToCharArray(); string a = ""; int last = 0; for (int i = 0; i <= charArray.Length-1; i++) { if (!IsHebrew(charArray[i])) { List<char> temp = new List<char>(); for (; last < i; last++) {

Categories : C#

How to insert single value in single cell to CSV file?
The code is working fine because the result is: TobRod Porosity,Batch code,Nu.,PAD,G.Po,L.PoD Col1 Row 2,Col2 Row 2,Col3 Row 2 Can you confirm this? Here is how it is displayed on my PC: If you see all the values in a single cell on your machine, this means that there is a problem identifying the correct separator. In order to fix this, add this line: sep=, at the beginning of your CSV con

Categories : C#

select every x elements of a list in c#
Use Skip and Taks int count = 0; while(count < originalList.Count / 5) { var list = originalList.Skip(count * 5).Take(5); //now you have 5 elements in list, and with them you can operate. //please be aware to check if list has 5 elements. count++; }

Categories : C#

parallel execution using selenium and c# in VSTS integrating with MTM
You can only have a single instance of a browser based Coded UI test. In order to run multiple tests, you will need to have multiple test agents and then send tests to each agent from the Test Controller.

Categories : C#

unable to read data from the transport connection the connection was closed
I suggest that you get the html/texts first to your local machine before you load it to your agility pack. you can use HttpWebRequest it has timeout property if you really need to adjust it. look on this >> How can I download HTML source in C#

Categories : C#

How to access data in ObservableCollection from ViewModel?
I advise you to read through the Data Binding Overview page on MSDN first... you need to learn about data binding. A typical set up would look like this: Your view model: public ObservableCollection<User> Users { get { return users; } set { users = value; NotifyPropertyChanged("Users"); } } public User SelectedUser { get { return user; } set { user = value; NotifyPropertyC

Categories : C#

Datepicker and allowing multiple input formats
Throwing exceptions each step costs a lot performance. Get rid of try{} catch{}, the for loop and use the very user-friendly TryParseExact. It will accept your 'checks' array variable. if(DateTime.TryParseExact(value as string, checks, CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)) { // success }

Categories : C#

Extension for IEnumerable
One possible kick-it-in-the-teeth solution is to force it back to an object before casting to an Enum: public static String Humanize<T>(this IEnumerable<T> source) where T : struct, IConvertible { return String.Join(", ", source.Cast<T>().Select(x => ((Enum)((object)x)).Attribute<DescriptionAttribute>().Description)); } This worked for me and printed the descripti

Categories : C#

Mapping platform specific interoperable types
INT_PTR and LONG_PTR are the same size as a pointer. So, they will be 32 bits wide in 32 bit targets, and 64 bits wide in 64 bit targets. It is simply wrong in C# to use either int or long since they have fixed sizes. The correct translation for both INT_PTR and LONG_PTR to C# is as IntPtr. Similarly, for the unsigned variants, use UIntPtr.

Categories : C#




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.