Can we find all tables in the msaccess using sql .
as we do in sqlserver
select * from sys.tables
in sqlite
SELECT * FROM sqlite_master where type='table'
Hi guys,
I have an object with different values that is name,nameid, lifebeging,lifeEndiging .... etc,
for loop
{
Search *Obj=[artistslist objectAtIndex:i];// here i will get name, ids, other value for each objcet
}
0 obj.name= //string values1 get from parser
1 obj.name= //string values1
2 obj.name= //string values1
3 obj.name= //string values1
4 obj.name= //string values1
I am getting values in the artistList then i need to sort only by name not other feilds
when i use this below statement
[artistsList sortUsingSelector:@selector(NSOrderedAscending:)];
i am getting exception here ,it is not working.
I have a large data set which I know contains many dupicate records. Basically I have data on first name, last name, different address components and date of birth.
I think the best way to do this is to use the name and date of birth as chances are if these things match, it's the same person. There are probably lots of instances where there are slight differences in spelling (like typos missing a single letter) or use of name (ie: some might have a middle initial in first name column) which would be good to account for, but I'm not sure how to approach this.
Are there any tools or articles on going about this process? The data is all in a MySQL database and I have a basic proficiency in SQL.
I am trying to make a simple photo gallery website. Using ASP.NET and C#.
Right now I don't have a server set up but I am just using the development one that Visual Studio Starts when you make a website project and run it.
I have a folder on my hard drive that contains an unknown number of images. I want to write a piece of code that will go through each image and add them to the default webpage. I have tried this code but it doesn't work. What am I doing wrong? Should I be using a ListView control or a DataView or something like that? Do I need to add a virtual directory in order to access the images? If so, how do I to that on this test server?
ALSO, how do I set the position and alignment of these pictures?
For example, how would I make it so that the pictures are in a line vertically and centered on the webpage?
protected void Page_Load(object sender, EventArgs e)
{
string[] filesindirectory = Directory.GetFiles(@"C:\Users\Jordan\Desktop\Web Images");
int i = 1;
foreach (string s in filesindirectory)
{
Image img = new Image();
img.ID = "image" + i.ToString();
img.ImageUrl = s;
img.Visible = true;
Page.Controls.Add(img);
i++;
}
}
Having successfully gotten a sample program working, I'm now starting
to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class
heirarchy.
It's a scientific instrumentation application, and the classes I'm
mapping have several properties that are arrays of floats e.g.
private float[] _rawY;
public virtual float[] RawY
{
get
{
return _rawY;
}
set
{
_rawY = value;
}
}
These arrays can contain a maximum of 500 values.
I didn't expect Automapping to work on arrays, but tried it anyway,
with some success at first. Each array was auto mapped to a BLOB
(using SQLite), which seemed like a viable solution.
The first problem came when I tried to call SaveOrUpdate on the
objects containing the arrays - I got "No persister for float[]"
exceptions.
So my next thought was to convert all my arrays into ILists e.g.
public virtual IList<float> RawY { get; set; }
But now I get:
NHibernate.MappingException: Association references unmapped class: System.Single
Since Automapping can deal with lists of complex objects, it never
occured to me it would not be able to map lists of basic types. But
after doing some Googling for a solution, this seems to be the case.
Some people seem to have solved the problem, but the sample code I
saw requires more knowledge of NHibernate than I have right now - I
didn't understand it.
Questions:
1. How can I make this work with Automapping?
2. Also, is it better to use arrays or lists for this application?
I can modify my app to use either if necessary (though I prefer
lists).
Edit:
I've studied the code in Mapping Collection of Strings, and I see there is test code in the source that sets up an IList of strings, e.g.
public virtual IList<string> ListOfSimpleChildren { get; set; }
[Test]
public void CanSetAsElement()
{
new MappingTester<OneToManyTarget>()
.ForMapping(m => m.HasMany(x => x.ListOfSimpleChildren).Element("columnName"))
.Element("class/bag/element").Exists();
}
so this must be possible using pure Automapping, but I've had zero luck getting anything to work, probably because I don't have the requisite knowlege of manually mapping with NHibernate.
Starting to think I'm going to have to hack this (by encoding the array of floats as a single string, or creating a class that contains a single float which I then aggregate into my lists), unless someone can tell me how to do it properly.
End Edit
Here's my CreateSessionFactory method, if that helps formulate a
reply...
private static ISessionFactory CreateSessionFactory()
{
ISessionFactory sessionFactory = null;
const string autoMapExportDir = "AutoMapExport";
if( !Directory.Exists(autoMapExportDir) )
Directory.CreateDirectory(autoMapExportDir);
try
{
var autoPersistenceModel =
AutoMap.AssemblyOf<DlsAppOverlordExportRunData>()
.Where(t => t.Namespace == "DlsAppAutomapped")
.Conventions.Add( DefaultCascade.All() )
;
sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard
.UsingFile(DbFile)
.ShowSql()
)
.Mappings(m => m.AutoMappings.Add(autoPersistenceModel)
.ExportTo(autoMapExportDir)
)
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory()
;
}
catch (Exception e)
{
Debug.WriteLine(e);
}
return sessionFactory;
}
I want to select and group the products, and rank them by the number of times they occur.
For example, I have an OrderList each of order object has a OrderProductVariantList(OrderLineList), and each of OrderProductVariant object has ProductVariant, and then the ProductVariant object will have a Product object which contains product information.
A friend helped me with the following code. It could be compiled, but it did not return any value/result. I used the watch window for the query and it gave me "The name 'query' does not exist in the current context".
Can anyone help me?
Many thanks.
var query = orderList.SelectMany( o => o.OrderLineList )
// results in IEnumerable<OrderProductVariant>
.Select( opv => opv.ProductVariant )
.Select( pv => p.Product )
.GroupBy( p => p )
.Select( g => new {
Product = g.Key,
Count = g.Count()
});
Hi,
I would like my listbox to number each item using the SelectedIndex property + 1.
How would I do that to the Text property of a TextBlock
in a DataTemplate of the listbox???
Malcolm
EDIT: i dont think I mean the Selectedindex just the index of the listboxitem.
I was wondering if there was some sort of cheat sheet for which objects go well with the using statement... SQLConnection, MemoryStream, etc.
Taking it one step further, it would be great to even show the other "pieces of the puzzle", like how you should actually call connection.Close() before the closing using statement bracket.
Anything like that exist? If not, maybe we should make one.
I've got a ItemsControl (to be replaced by listbox) which has it's ItemsSource bound to an ObservableCollection<User> which is located in the view model.
The View Model contains some DelegateCommand<T> delegates for handling commands (for instance UpdateUserCommand and RemoveUserCommand). All works fine if the buttons linked to those commands are placed outside of the DataTemplate of the control which is presenting the items.
<ItemsControl ItemsSource="{Binding Users, Mode=TwoWay}" HorizontalContentAlignment="Stretch">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding UserName}"/>
<PasswordBox Grid.Column="1" Password="{Binding UserPass}"/>
<TextBox Grid.Column="2" Text="{Binding UserTypeId}"/>
<Button Grid.Column="3" Content="Update" cal:Click.Command="{Binding UpdateUserCommand}" cal:Click.CommandParameter="{Binding}"/>
<Button Grid.Column="4" Content="Remove" cal:Click.Command="{Binding RemoveUserCommand}" cal:Click.CommandParameter="{Binding}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
What I'm trying to achieve, is : Have each row - generated by the ListView/ItemsControl - contain buttons to manage the item represented that particular row.
During the runtime, the VS's output panel generated the following messages for each listbox element
System.Windows.Data Error: BindingExpression path error: 'UpdateUserCommand' property not found on 'ModuleAdmin.Services.User' 'ModuleAdmin.Services.User' (HashCode=35912612). BindingExpression: Path='UpdateUserCommand' DataItem='ModuleAdmin.Services.User' (HashCode=35912612); target element is 'System.Windows.Controls.Button' (Name=''); target property is 'Command' (type 'System.Windows.Input.ICommand')..
System.Windows.Data Error: BindingExpression path error: 'RemoveUserCommand' property not found on 'ModuleAdmin.Services.User' 'ModuleAdmin.Services.User' (HashCode=35912612). BindingExpression: Path='RemoveUserCommand' DataItem='ModuleAdmin.Services.User' (HashCode=35912612); target element is 'System.Windows.Controls.Button' (Name=''); target property is 'Command' (type 'System.Windows.Input.ICommand')..
Which would imply that there are binding errors present.
Is there any way to make this right? or is this not the way?
I expected to get a grid of unique random numbers. Instead each row is the same sequence of numbers. What's going on here?
from pprint import pprint
from random import random
nrows, ncols = 5, 5
grid = [[0] * ncols] * nrows
for r in range(nrows):
for c in range(ncols):
grid[r][c] = int(random() * 100)
pprint(grid)
Example output:
[[64, 82, 90, 69, 36],
[64, 82, 90, 69, 36],
[64, 82, 90, 69, 36],
[64, 82, 90, 69, 36],
[64, 82, 90, 69, 36]]
I have written some antivirus software in Python, but am unable to find virus signatures. The software works by dumping each file on the hard disk to hex, thus getting the hex signature. Where do i get signatures for all the known viruses?
I am trying to implement an OutOfStockException for when the user attempts to buy more items than there are available. I'm not sure if my implementation is correct. Does this look OK to you?
public class OutOfStockException extends Exception {
public OutOfStockException(){
super();
}
public OutOfStockException(String s){
super(s);
}
}
This is the class where I need to test it:
import javax.swing.JOptionPane;
public class SwimItems {
static final int MAX = 100;
public static void main (String [] args)
{
Item [] items = new Item[MAX];
int numItems;
numItems = fillFreebies(items);
numItems += fillTaxable(items,numItems);
numItems += fillNonTaxable(items,numItems);
sellStuff(items, numItems);
}
private static int num(String which) {
int n = 0;
do {
try{
n=Integer.parseInt(JOptionPane.showInputDialog("Enter number of "+which+" items to add to stock:"));
}
catch(NumberFormatException nfe){
System.out.println("Number Format Exception in num method");
}
} while (n < 1 || n > MAX/3);
return n;
}
private static int fillFreebies(Item [] list)
{
int n = num("FREEBIES");
for (int i = 0; i < n; i++)
try{
list [i] = new Item(JOptionPane.showInputDialog("What freebie item will you give away?"),
Integer.parseInt(JOptionPane.showInputDialog("How many do you have?")));
}
catch(NumberFormatException nfe){
System.out.println("Number Format Exception in fillFreebies method");
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array Index Out Of Bounds Exception in fillFreebies method");
}
return n;
}
private static int fillTaxable(Item [] list, int number)
{
int n = num("Taxable Items");
for (int i = number ; i < n + number; i++)
try{
list [i] = new TaxableItem(JOptionPane.showInputDialog("What taxable item will you sell?"),
Double.parseDouble(JOptionPane.showInputDialog("How much will you charge (not including tax) for each?")),
Integer.parseInt(JOptionPane.showInputDialog("How many do you have?")));
}
catch(NumberFormatException nfe){
System.out.println("Number Format Exception in fillTaxable method");
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array Index Out Of Bounds Exception in fillTaxable method");
}
return n;
}
private static int fillNonTaxable(Item [] list, int number)
{
int n = num("Non-Taxable Items");
for (int i = number ; i < n + number; i++)
try{
list [i] = new SaleItem(JOptionPane.showInputDialog("What non-taxable item will you sell?"),
Double.parseDouble(JOptionPane.showInputDialog("How much will you charge for each?")),
Integer.parseInt(JOptionPane.showInputDialog("How many do you have?")));
}
catch(NumberFormatException nfe){
System.out.println("Number Format Exception in fillNonTaxable method");
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array Index Out Of Bounds Exception in fillNonTaxable method");
}
return n;
}
private static String listEm(Item [] all, int n, boolean numInc)
{
String list = "Items: ";
for (int i = 0; i < n; i++)
{
try{
list += "\n"+ (i+1)+". "+all[i].toString() ;
if (all[i] instanceof SaleItem) list += " (taxable) ";
if (numInc) list += " (Number in Stock: "+all[i].getNum()+")";
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array Index Out Of Bounds Exception in listEm method");
}
catch(NullPointerException npe){
System.out.println("Null Pointer Exception in listEm method");
}
}
return list;
}
private static void sellStuff (Item [] list, int n) {
int choice;
do {
try{
choice = Integer.parseInt(JOptionPane.showInputDialog("Enter item of choice: "+listEm(list, n, false)));
}
catch(NumberFormatException nfe){
System.out.println("Number Format Exception in sellStuff method");
}
}while (JOptionPane.showConfirmDialog(null, "Another customer?")==JOptionPane.YES_OPTION);
JOptionPane.showMessageDialog(null, "Remaining "+listEm(list, n, true));
}
}
Hello..
I am trying to get all of the "video" elements and their attributes from an XML file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<videos>
<video title="video1" path="videos\video1.wma"/>
<video title="video2" path="videos\video2.wma"/>
<video title="video3" path="videos\video3.wma"/>
</videos>
The following will only select the root node and all of the children. I would like to get all of the 'video' elements into the IEnumerable. Can someone tell me what I'm doing wrong?
IEnumerable<XElement> elements = from xml in _xdoc.Descendants("videos")
select xml;
The above returns a collection with a length == 1. It contains the root element and all the children.
There is a trait called Kleisli in the scalaz library. Looking at the code:
import scalaz._
import Scalaz._
type StringPair = (String, String)
val f: Int => List[String] = (i: Int) => List((i |+| 1).toString, (i |+| 2).toString)
val g: String => List[StringPair] = (s: String) => List("X" -> s, s -> "Y")
val k = kleisli(f) >=> kleisli(g) //this gives me a function: Int => List[(String, String)]
Calling the function k with the value of 2 gives:
println( k(2) ) //Prints: List((X,3), (3,Y), (X,4), (4,Y))
My question is: how would I use Scalaz to combine f and g to get a function m such that the output of m(2) would be:
val m = //??? some combination of f and g
println( m(2) ) //Prints: List((X,3), (X,4), (3,Y), (4,Y))
Is this even possible?
I've used MSDataSetGenerator a fair bit and it causes a bunch of pain because the XMLSerializer rarely works on the output. Are there any other code generators that come with the SDK?
How can I use a TEnumerator to go through my TDictionary in sorted order by key?
I've got something like this:
var
Dic: TDictionary<string, string>;
begin
Dic := TDictionary<string, string>.create;
Dic.Add('Tired', 'I have been working on this too long');
Dic.Add('Early', 'It is too early in the morning to be working on this');
Dic.Add('HelpMe', 'I need some help');
Dic.Add('Dumb', 'Yes I know this example is dumb');
{ The following is what I don't know how to do }
for each string1 (ordered by string1) in Dic do
some processing with the current Dic element
Dic.Free;
end;
So I would like to process my dictionary in the order: Dumb, Early, HelpMe, Tired.
Unfortunately the Delphi help is very minimal in describing how TEnumerator works and gives no examples that I can find. There is also very little written on the web about using Enumerators with Generics in Delphi.
I'm really new to C - Python interaction and am currently writing a small app in C which will read a file (using Python to parse it) and then using the parsed information to execute small Python snippets. At the moment I'm feeling very much like I'm reinventing wheels, for example this function:
typedef gpointer (list_func)(PyObject *obj);
GList *pylist_to_glist(list_func func, PyObject *pylist)
{
GList *result = NULL;
if (func == NULL)
{
fprintf(stderr, "No function definied for coverting PyObject.\n");
}
else if (PyList_Check(pylist))
{
PyObject *pIter = PyObject_GetIter(pylist);
PyObject *pItem;
while ((pItem = PyIter_Next(pIter)))
{
gpointer obj = func(pItem);
if (obj != NULL) result = g_list_append(result, obj);
else fprintf(stderr, "Could not convert PyObject to C object.\n");
Py_DECREF(pItem);
}
Py_DECREF(pIter);
}
return result;
}
I would really like to do this in a easier/smarter way less prone to memory leaks and errors.
All comments and suggestions are appreciated.
I have 2 entities, Task and List. Each task has a to-one relationship to a List object called "list", and there is an inverse relationship with List, which has a to-many relationship with Task called "tasks".
I'm trying to use a fetch request with an NSPredicate to get all the Task objects that belong to a specified List:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"list=%@", theList];
[fetchRequest setPredicate:predicate];
(where "theParent" is a reference to a List object). However this returns no fetched objects. If I take out the predicate, then the objects are returned (so I do know they exist, and by NSLogging theList I know it has Task objects associated with it).
Thanks
I'm doing the following code to filter a list of objects before it gets sent off to be printed.
Dim printList As New List(Of dispillPatient)
For Each pat As dispillPatient In patList
If (From meds In pat.Medication Select meds Where meds.Print = True).Count > 0 Then
Dim patAdd As New dispillPatient
patAdd = pat
patAdd.Medication = DirectCast((From meds In pat.Medication Select meds Where meds.Print = True).ToList, List(Of dispillMedication))
printList.Add(patAdd)
End If
Next
What is happening is patList, which is my initial list, for every dispillPatient inside of it, that specific patients Medication object (which is another list), is being shorten to the list that is returned to the patAdd object.
I think this has something to do with both the way that .NET makes the copy of my pat object when I do patAdd = pat and the LINQ query that I'm using. Has anyone had a similar issue before and\or what can I do to keep my initial list from getting truncated.
Thanks
Its great when you can return a null/empty object in most cases to avoid nulls, but what about Collection like objects?
In Java, Map returns null if key in get(key) is not found in the map.
The best way I can think of to avoid nulls in this situation is to return an Entry<T> object, which is either the EmptyEntry<T>, or contains the value T.
Sure we avoid the null, but now you can have a class cast exception if you don't check if its an EmptyEntry<T>.
Is there a better way to avoid nulls in Map's get(K)?
And for argument sake, let's say this language don't even have null, so don't say just use nulls.
Hello, is there anyway to unbox an object to its real type?
Basically I am given an ArrayList, the array list are actually a list of int or double, or maybe other types ( it can be either, but it is either all int or double, no mix). Now, I will have to return a List<double> or List<int> or other list, depending on what is the real type.
public List<T> ConvertToList<T>(ArrayList arr)
{
var list1 = new List<T>();
foreach(var obj in arr)
{
// how to do the conversion?
var objT = ??
list1.Add(objT);
}
return list1;
}
Any idea?