Search Results

Search found 18661 results on 747 pages for 'linq to mysql'.

Page 20/747 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • How to deal with MySQL Connector/ODBC error "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'"

    - by user12653020
    I am sure many users run into a mysterious problem when perfectly working ODBC configurations started failing with errors like: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' The above error message might be preceded with something like [nxDc[yQ]. At the same time odbc.ini specifies in its DSN different SOCKET=/tmp/mysql.sock or a TCP connection SERVER=<remote_host_or_ip>. The question is, what had happened that the ODBC driver started to ignore the DSN options? The clue lies in the corrupted string [nxDc[yQ], which actually was [UnixODBC][MySQL] with each 2nd symbol removed. This is the case of bad conversion from SQLCHAR to SQLWCHAR. The UnixODBC driver manager took a single-byte character string from the client application and tried to convert it into the wide (multi-byte) characters for the Unicode version of MyODBC driver: Initially the piece of the connection string was represented by 1-byte chars like: [S][E][R][V][E][R][=][m][y][h][o][s][t][;] after the bad conversion to wide chars (commonly 2-byte UTF-16) [SE][RV][ER][=m][yh][os][t;] instead of [S\0][E\0][R\0][V\0][E\0][R\0][=\0][m\0][y\0][h\0][o\0][s\0][t\0][;\0] Naturally, the MyODBC driver could not parse the bad string and tried to use the default connection type (SOCKET) with the default value (/var/lib/mysql/mysql.sock) Now we know what happened, but why it happened? In most cases it happened because of using ODBCManageDataSourcesQ4 utility or its older analog ODBCConfig. When registering ODBC drivers they put lots of additional options and one of these options badly affects the UnixODBC driver manager itself. The solution is simple - remove or comment out the option in odbcinst.ini file (it is empty by default) set for the driver: [MySQL ODBC 5.2.6 Driver] Description    = Driver         = /home/dbs/myodbc526/lib/libmyodbc5w.so Driver64       = /home/dbs/myodbc526/lib/libmyodbc5w.so Setup          = /home/dbs/myodbc526/lib/libmyodbc5S.so Setup64        = /home/dbs/myodbc526/lib/libmyodbc5S.so UsageCount     = 1 CPTimeout      = 0 CPTimeToLive   = 0 IconvEncoding  =  # <--------- remove this line Trace          = TraceFile      = TraceLibrary   = After applying this simple solution (remove the line with IconvEncoding = ) everything came to normal. Prior to removing that line I tried putting different encoding names there, but the result was not good, so I really don't know how to properly use it. Unfortunately, UnixODBC manuals say nothing about it. Therefore, removing this option was the only way to get things done.

    Read the article

  • Installing mysql on leopard: "Can't connect to local MySQL server through socket"

    - by Neil
    I migrated to a new machine and used migration assistant to copy across my files (which seemed to copy across the DBs) but I had to use macports to install Mysql (whereas last time I compiled from source via Dan Benjamin's guide). For some reason, mysql is intermittently throwing the following error; Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2) It does this no matter what I try, which has included setting the socket in /opt/local/etc/mysql5/my.cnf. Previously I've managed to temporarily fix this by restarting the machine, but right now it just doesn't want to know, despite grep mysql telling me I seem to have a pid; 0 46 1 0 0:00.01 ?? 0:00.01 /opt/local/bin/daemondo --label=mysql5 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart ; --pid=none 0 70 1 0 0:00.01 ?? 0:00.01 /bin/sh /opt/local/lib/mysql5/bin/mysqld_safe --datadir=/opt/local/var/db/mysql5 --pid-file=/opt/local/var/db/mysql5/localhost.pid 74 100 70 0 0:09.22 ?? 1:02.68 /opt/local/libexec/mysqld --basedir=/opt/local --datadir=/opt/local/var/db/mysql5 --user=mysql --pid-file=/opt/local/var/db/mysql5/localhost.pid --socket=/tmp/mysql.sock 501 66217 65266 0 0:00.00 ttys001 0:00.00 grep mysql How do I fix this? Are there any steps I can take next? I've been trying for a few weeks now and I've read round all relevant blog posts, so I'm completely out of ideas.

    Read the article

  • OrderBy and Distinct using LINQ-to-Entities

    - by BlueRaja
    Here is my LINQ query: (from o in entities.MyTable orderby o.MyColumn select o.MyColumn).Distinct(); Here is the result: {"a", "c", "b", "d"} Here is the generated SQL: SELECT [Distinct1].[MyColumn] AS [MyColumn] FROM ( SELECT DISTINCT [Extent1].[MyColumn] AS [MyColumn] FROM [dbo].[MyTable] AS [Extent1] ) AS [Distinct1] Is this a bug? Where's my ordering, damnit?

    Read the article

  • LINQ to SQL get grouped MIN with JOIN

    - by Ira Rainey
    I'm having trouble with a LINQ to SQL query getting the min value using Visual Basic. Here's the SQL: SELECT RC.AssetID, MIN(RC.RecCode) AS RecCode, JA.EngineerNote from JobAssetRecCode RC JOIN JobAssets JA ON JA.AssetID = RC.AssetID AND JA.JobID = RC.JobID WHERE RC.InspState = 2 AND RC.RecCode > 0 AND RC.JobID = @JobID GROUP BY RC.AssetID, JA.EngineerNote; I seem to be going around in circles here with grouping etc not managing to get it working. Any help would be greatly appreciated.

    Read the article

  • LINQ to SQL select distinct from multiple colums

    - by Morron
    Hi, I'm using LINQ to SQL to select some columns from one table. I want to get rid of the duplicate result also. Dim customer = (From cus In db.Customers Select cus.CustomerId, cus.CustomerName).Distinct Result: 1 David 2 James 1 David 3 Smith 2 James 5 Joe Wanted result: 1 David 2 James 3 Smith 5 Joe Can anyone show me how to get the wanted result? Thanks.

    Read the article

  • Using linq to combine objects

    - by DotnetDude
    I have 2 instances of a class that implements the IEnumerable interface. I would like to create a new object and combine both of them into one. I understand I can use the for..each to do this. Is there a linq/lambda expression way of doing this?

    Read the article

  • Updating multiple tables at the same time in Linq-to-SQL

    - by kiran
    How do I update two tables at the same time using Linq-to-SQL? var z = from a in db.Products join b in db.ProductSubcategories on a.ProductSubcategoryID equals b.ProductSubcategoryID join d in db.ProductCategories on b.ProductCategoryID equals d.ProductCategoryID select new { ProductName = a.Name, ProductCategory = d.Name, ProductSubCategory = b.Name, Cost = a.StandardCost, discontinuedDate = a.DiscontinuedDate, ProductId=a.ProductID };

    Read the article

  • Dynamic LINQ OrderBy

    - by John Sheehan
    I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a sql-like string (e.g. OrderBy("Name, Age DESC")) for ordering. Unfortunately, the method included only works on IQueryable<T>. Is there any way to get this functionality on IEnumerable<T>?

    Read the article

  • c# linq to xml dynamic query

    - by David Archer
    Right, bit of a strange question; I have been doing some linq to XML work recently (see my other recent posts here and here). Basically, I want to be able to create a query that checks whether a textbox is null before it's value is included in the query, like so: XDocument db = XDocument.Load(xmlPath); var query = (from vals in db.Descendants("Customer") where (if(textbox1.Text != "") {vals.Element("CustomerID") == Convert.ToInt32(textbox1.Text) } || if(textbox2.Text != "") {vals.Element("Name") == textbox2.Text}) select vals).ToList();

    Read the article

  • Order by descending is not working on LINQ to Entity

    - by Vinni
    Order by descending is not working on LINQ to Entity In the following Query In place of ascending If I keep descending it is not working. Please help me out var hosters = from e in context.Hosters_HostingProviderDetail where e.ActiveStatusID == pendingStateId orderby e.HostingProviderName ascending select e; return hosters.ToList();

    Read the article

  • Linq-to-SQL: How to perform a count on a sub-select

    - by Peter Bridger
    I'm still trying to get my head round how to use LINQ-to-SQL correctly, rather than just writing my own sprocs. In the code belong a userId is passed into the method, then LINQ uses this to get all rows from the GroupTable tables matching the userId. The primary key of the GroupUser table is GroupUserId, which is a foreign key in the Group table. /// <summary> /// Return summary details about the groups a user belongs to /// </summary> /// <param name="userId"></param> /// <returns></returns> public List<Group> GroupsForUser(int userId) { DataAccess.KINv2DataContext db = new DataAccess.KINv2DataContext(); List<Group> groups = new List<Group>(); groups = (from g in db.Groups join gu in db.GroupUsers on g.GroupId equals gu.GroupId where g.Active == true && gu.UserId == userId select new Group { Name = g.Name, CreatedOn = g.CreatedOn }).ToList<Group>(); return groups; } } This works fine, but I'd also like to return the total number of Users who are in a group and also the total number of Contacts that fall under ownership of the group. Pseudo code ahoy! /// <summary> /// Return summary details about the groups a user belongs to /// </summary> /// <param name="userId"></param> /// <returns></returns> public List<Group> GroupsForUser(int userId) { DataAccess.KINv2DataContext db = new DataAccess.KINv2DataContext(); List<Group> groups = new List<Group>(); groups = (from g in db.Groups join gu in db.GroupUsers on g.GroupId equals gu.GroupId where g.Active == true && gu.UserId == userId select new Group { Name = g.Name, CreatedOn = g.CreatedOn, // ### This is the SQL I would write to get the data I want ### MemberCount = ( SELECT COUNT(*) FROM GroupUser AS GU WHERE GU.GroupId = g.GroupId ), ContactCount = ( SELECT COUNT(*) FROM Contact AS C WHERE C.OwnerGroupId = g.GroupId ) // ### End of extra code ### }).ToList<Group>(); return groups; } }

    Read the article

  • Load parent and child table in one query linq to entitiy

    - by parminder
    Hi Experts, I have a following tables/classes structure in Linq to entities. ` Books { bookId, Title } Tags { TagId Tag } BooksTags { BookId TagId } ' Now I need to write a query which gives me result like this Class Result { bookId, Title Tags } Tags should be comma separated text from the tags table by joining all three tables. How to get it done. Thanks Parminder

    Read the article

  • Get sum of two columns in one LINQ query

    - by Axarydax
    Hi, let's say that I have a table called Items (ID int, Done int, Total int) I can do it by two queries: int total = m.Items.Sum(p=>p.Total) int done = m.Items.Sum(p=>p.Done) But I'd like to do it in one query, something like this: var x = from p in m.Items select new { Sum(p.Total), Sum(p.Done)}; Surely there is a way to call aggregate functions from LINQ syntax...?

    Read the article

  • Convert this Linq query from query syntax to lambda expression

    - by Jinkinz
    I'm not sure I like linq query syntax...its just not my preference. But I don't know what this query would look like using lambda expressions, can someone help? from securityRoles in user.SecurityRoles from permissions in securityRoles.Permissions where permissions.SecurableEntity.Name == "Unit" && permissions.PermissionType.Name == "Read" orderby permissions.PermissionLevel.Value descending select permissions There is a many-to-many relationship between users and security roles that makes this extra confusing. Thanks! Kelly

    Read the article

  • sql to xml using linq - nested collections

    - by nelsonwebs
    I have a table of data that looks something like this. name, hour, price1, price2, price3, price4, price5 fred, 3, 12.5, 13.5, 14, 15, 16 dave, 6, 8, 12, 18, 20.2, 25 fred, 6, 10, 11, 14, 15, 19.7 This table needs to be output to an xml file that looks like this. <timeCost> <person name="fred"> <time hour="5"> <cost price="12.5" /> <cost price="13.5" /> <cost price="14" /> <cost price="15" /> <cost price="16" /> </time> <time hour="6"> <cost price="10" /> <cost price="11" /> <cost price="14" /> <cost price="15" /> <cost price="19.7" /> </time> </person> <person name="dave"> <time hour="6"> <cost price="8" /> <cost price="12" /> <cost price="18" /> <cost price="20.2" /> <cost price="25" /> </time> </person> </timeCost> I have a linq query to get the data from SQL something like this. // initialize data context var people = from p in dc.people orderby p.name, p.hour select p; However, I'm having trouble writing the xml out using linq (csharp). Specifically, the problem is I don't know how to deal with having multiple time nodes under each name node (nested loops/collections). How can this be done? This is a sql 08 ent db if it matters to anyone.

    Read the article

  • Select most recent records using LINQ to Entities

    - by begemotya
    I have a simple Linq to Enities table to query and get the most recent records using Date field So I tried this code: IQueryable<Alert> alerts = GetAlerts(); IQueryable latestAlerts = from a in alerts group a by a.UpdateDateTime into g select g.OrderBy(a = a.Identifier).First(); Error: NotSupportedException: The method 'GroupBy' is not supported. Is there any other way to get do it? Thanks a lot!

    Read the article

  • LINQ: Create persistable Associations in Code, Without Foreign Key

    - by Alex
    Hello, I know that I can create LINQ Associations without a Foreign Key. The problem is, I've been doing this by adding the [Association] attribute in the DBML file (same as through the designer), which will get erased again after I refresh my database (and reload the entire table structure). I know that there is the MyData.cs file (as part of the DBML) in which I can place my partial extensions etc. to domain objects (to persist even after I refresh the DBML), but I don't know how to create an association there?

    Read the article

  • 'Contains()' workaround using Linq to Entities?

    - by jbloomer
    I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to Contains not being supported? I want to do something like this: List<long?> txnIds = new List<long?>(); // Fill list var q = from t in svc.OpenTransaction where txnIds.Contains(t.OpenTransactionId) select t;

    Read the article

  • C# & ASP.Net - determine linq query generation time

    - by Chris Klepeis
    I'd like to detemine the amount of time it takes for my ASP.Net program to generate certain sql queries using linq.... note - I want the query generation time, not the query execution time. Is this possible, or even feasable (if its usually fast)? My website has some heavy traffic and I want to cover all of my bases.

    Read the article

  • LINQ to SQL associations - how to change the value of associated field

    - by HAdes
    I have 2 classes with a LINQ association between them i.e.: Table1: Table2: ID ID Name Description ForiegnID The association here is between Table1.ID - Table2.ForiegnID I need to be able to change the value of Table2.ForiegnID, however I can't and think it is because of the association (as when I remove it, it works). Therefore, does anyone know how I can change the value of the associated field Table2.ForiegnID? Thanks.

    Read the article

  • Add elements to XDocument after LINQ Query

    - by Jon
    I have the following XML LINQ query from my XDocument. var totals = (from x in MyDocument.Descendants("TOTALS") select x).FirstOrDefault(); Once I have found my totals node I need to add some elements to that node and push that change to the XDocument.

    Read the article

  • Stored Functions with Linq to Entities

    - by Lawnmower
    Hi, How can I make a MS-SQL stored function availabe in LINQ expressions if using the Entity framework? The SQL function was created with CREATE FUNCTION MyFunction(@name) ...). I was hoping to access it similarly to this: var data = from c in entities.Users where MyFunction(c.name) = 3; Unfortunately I have only .NET 3.5 available.

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >