C# :: Linq To SQL Query Not Directly Working But SQL Result Text Works
Apr 14, 2015
I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.
However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:
DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);
and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.
var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);
View 8 Replies
ADVERTISEMENT
Oct 29, 2013
I entered to Visual C++ 2010. Now my intention is to prepare a LINQ Query to select a distinct value from a datatable...
In C# My Query
============
var ProjLnkQry = (from P in MyClass1.ProjTbl.AsEnumerable() select P["proj_name"]).Distinct().ToList();
The above query I try to convert it into VIsual C++
auto DistDepQry=(from v1 in MyGlobalData::ProjectTbl::AsEnumaerable() select v1["depart_name"])->Distinct()->ToList();
But not succeeded.... I found the error like : "from" undeclared Identifier.....
View 2 Replies
View Related
Apr 2, 2014
I am having a problem using fprintf. I have a function which flips a coin. Heads prints a text to the screen. Tails prints a different text to the screen. My problem is getting the result to print to a text file.
Code:
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
void seedrnd(void);
int coinflip(int small, int large);
}
[code]....
View 12 Replies
View Related
Jan 11, 2015
I am trying to take text from a file and have it displayed using fprintf at line 46. When I run the below code nothing prints out. My text file has 4 lines with 5 different strings separated by whitespace.
#include <cstdlib>
#include <vector>
#include <cstring>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
using namespace std;
//declare my own struct
[Code]...
View 7 Replies
View Related
Dec 6, 2013
i have turbo c++ 3.0 installed . my program is compiled without error and is running. but when i choose option to display scores in the consol , it hangs . check my code. i have to run this on same compiler. i just want to display all the contenets of text file .
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
[Code].....
View 4 Replies
View Related
Mar 24, 2013
Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.
Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;
[Code] ....
View 6 Replies
View Related
Jul 23, 2014
I want some simple code which will return only the DriveInfo from one drive. I have the below code but it isn't displaying what I expect it to display, I have a feeling i'm using Linq wrong!
var dname = from n in System.IO.DriveInfo.GetDrives() where n.Name == "F" select n.VolumeLabel;
richTextBox2.AppendText(dname.ToString() + "
");
The above should return the devices VolumeLabel which is in port F.
Instead I get the following:
System.Linq.Enumerable+WhereSelectArrayIterator`2[System.IO.DriveInfo,System.String]
View 5 Replies
View Related
Apr 13, 2015
I am trying to query fields in a where clause using LINQ to SQL and for some reason I cannot figure out why it doesn't work:
var qryGetMonsterID = (from students in dbContext.tblStudentPersonals
where (students.givenname.Equals(fn)) && (students.familyname.Equals(ln)) && (students.middlename.Equals(mn)) && (students.email.Equals(e))
select students);
The returned SQL Syntax is:
SELECT [t0].[monsterid], [t0].[givenname], [t0].[middlename], [t0].[familyname], [t0].[homeaddress], [t0].[city], [t0].[state], [t0].[postal], [t0].[primaryphone], [t0].[secondaryphone], [t0].[email], [t0].[username], [t0].[lastmodified], [t0].[modifiedby]
FROM [dbo].[tblStudentPersonal] AS [t0]
WHERE ([t0].[givenname] = @p0) AND ([t0].[familyname] = @p1) AND ([t0].[middlename] = @p2) AND ([t0].[email] = @p3)
Not sure but the values for middle name could be null - because not everyone has a middle name and the same is true for e-mail.
View 6 Replies
View Related
Oct 17, 2013
I'm programming with VS2010, for windows 7. The user likes to use the windows classic theme, and I discovered that BS_MULTILINE style isn't working as I expect. When a button is pressed in the classic theme, it looks like there is a temporary margin added that causes the text to wrap only when the button is pushed. It works fine with any other theme.
View 1 Replies
View Related
Aug 26, 2014
I have an XML document, formatted as such:
<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>
Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.
I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?
View 14 Replies
View Related
Dec 5, 2014
i have stuck in a join and i cant figure out where the problem is, i have those tables
public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[Code].....
View 12 Replies
View Related
Apr 9, 2013
I have a datatable which comprises values from 1st January to march, something like this:
DataTable datatable = new DataTable("Employee");
datatable.Columns.Add("Date", typeof(string));
datatable.Columns.Add("Employee", typeof(string));
datatable.Columns.Add("Job1", typeof(double));
datatable.Columns.Add("Job2", typeof(double));
datatable.Rows.Add(new Object[] { "1/4/2013", "A", 1.3, 2 });
[Code] ....
The result should look like this for Job1:
Employee 1/7-1/13 1/14-1/20 1/21-1/27 1/28-2/3 and so on...
A sum of values for this 7 days
B
C
D
I want to add all the values of Job1 for each employee in a time range which is one week starting from monday to sunday. How can I group the Job1 values week wise and store them in another datatable.
View 4 Replies
View Related
Mar 27, 2014
Is there any way to read RAM memory directly. For say i want to access memory location 0x0100 to 0x120. How to do that. how to declare the variable, is it unsigned int. what is the type of read values it hex or ascii. how t cast it.
View 2 Replies
View Related
Mar 25, 2014
I'm successfully publishing an app to my website by publishing locally and then uploading the files but one of the options offered is to publish straight to the web site but I can't find anywhere to enter a user name and password for my web site. I could also do it with ftp but since the option is offered to publish directly to the web site I'd like to try that method. I'm using the Click Once method.
View 5 Replies
View Related
Apr 3, 2014
I have two tables
Orders
ID, CreatedDate,CustomerID
1, 03/04/2014, test
OrderDetails
ID,ProductId, ProductName,Quantity,Price,Total
1, 5, Toy, 5, 1.99, 9.95
I have a gridview, im using its 'datasource dropdownlist' to populate it, i have the SQL statement
SELECT Orders.ID, OrderDetails.ProductId, OrderDetails.ProductName, OrderDetails.Quantity, OrderDetails.Price, OrderDetails.Total FROM (OrderDetails INNER JOIN Orders ON OrderDetails.ID = Orders.ID) WHERE (Orders.CustomerId = ?)
where the '?' is parameters source = QueryString, and QueryStringField= email
i have a session that is the customerEmailId, so
string CustomerEmailID = (string)Session["email"];
Response.Redirect("MyAccount.aspx?email=" + CustomerEmailID);//i have tested it and customerEmailid is test
however nothing loads in the GridView
View 1 Replies
View Related
Aug 2, 2014
I have a C# WPF program that takes a SQL query and populates a column from an Oracle database into a listbox on the form. I would like to be able to compare all items populated in the listbox, and run a SQL query for each item, populating those values into a different listbox.
So far, I have this code:
string sql2 = "select unique apps.fnd_application_all_view.application_name, fnd_responsibility_vl.responsibility_name, fnd_form_functions_tl.user_function_name, fnd_form_functions.function_name, fnd_form_functions_tl.description, fnd_form_functions.type FROM fnd_compiled_menu_functions, fnd_form_functions, fnd_form_functions_tl, fnd_responsibility, fnd responsibility_vl, apps.fnd_application_all_view WHERE
[code]....
I would like to be able to basically take the "Responsibility_Name" value from the first listbox (lstResponsibilities), which is already populated, and use those values to in the "sql2" query to find the "Function_Name" and populate "Function_Name" in the second listbox (lstFunctions).
View 5 Replies
View Related
Nov 25, 2013
I wish to convert a character directly to a string for a top-secret project I'm working on. It needs to be portable across various machines with different sized Indians.
Code:
#include <stdio.h>
int main(void)
{
const int i = 0x0041;
const char *str_p = (char *) &i;
}
[code]....
I want this to output an 'A', but I'm not sure this code will work on my friend's mom's S/360.
View 2 Replies
View Related
Mar 5, 2014
I don't know how to put this really, but I finished a program in Qt, and i want to know how to make a .exe file for it, so i dont have to open Qt and build the program every time i use it.
View 2 Replies
View Related
Jun 9, 2013
I'm trying to solve the following problem:
Given a query, find all possible tokens, i.e. query-splits
Example:
query = New York Hotel
tokens = {New, York, Hotel, New York, New Hotel, ...., New Hotel York, Hotel New York, ...}
Given a query with word count n, the total number of tokens is:
n + n*(n-1) + n*(n-1)*(n-2) + ... + n! (any explicit formula available for this sum?)
Now, I have came across various code snippets to generate permutations for a string, but never for a sentence.
View 13 Replies
View Related
Sep 22, 2014
So I've been working on this for awhile and FINALLY got it to work. This is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
[Code] ....
As you can see I will have the Name and total right next to eachother.. Problem is I dont want to make a million MySQLCommands for each ID.. Is there a Way I can list all data in each label?
For instance the Select from Text will show all the text from each different ID
and the Select from STOCK-USED as total will show all the total for each ID
Instead of having to list them individually.
Even if I leave it to this
"Select text FROM `parts`";
It selects the 2nd ID in my database and displays its text.. Forgets about the first one completely ...
View 2 Replies
View Related
Jun 13, 2014
I have table called leavetable where in i have the fields eid, lfrom,lto, reason,status an employee will insert these fields in the leave form except status, status will be updated by admin but there is no unique field in the table so when the admin updates the status as cancel for an id emp001 so whereever this id is present in the table its getting updated to cancel even though it is approved previously.. How to avoid this duplication ?
SqlConnection con = new SqlConnection(Connectionstring);
con.Open();
string sql = "update leavetable set status = '"+status+"' where eid = '"+textBox1.Text+"' and noofdays = '"+textBox5.Text+"'";
[Code] .....
View 7 Replies
View Related
Nov 16, 2014
I have WCF web service which contains methods for communicating with database (ms sql). For a long time I was using pure sql statements, that aren't secure. It is time to move to parameterized queries. I'm using code-engine.com source code for query builder. Example of it is here: SelectQueryBuilder: Building complex and flexible SQL queries/commands from C# . Which works OK and I have no problems when is used inside of web service.
The problem: I also have asp.net web site which uses this webservice and the main problem is, how to build queries on client side and sent them to web service? I can build query on client side and send dbCommand.commandtext but I then I don't know how to send parameters list to webservice, because it isn't serialized.
This would be used as "universal" method for sql statements. I have others method like getUser(),getUsers(),getPages() but I really need this kind of methods to pass query to it.
View 1 Replies
View Related
Jul 23, 2014
i'm trying to update multiple table values with same column using one query.
Here's what i've tried so far:
mySql.CommandText = "Update tbl_employees,tbl_emp_additional_info,tbl_allocated_deductions,tbl_benefits,
tbl_cashadvances,tbl_deduction_history,"+
"tbl_dtr,tbl_empabsences,tbl_empstatus,tbl_otherdeductions
,tbl_ots,tbl_payroll_history,tbl_rdcomments,tbl_reversed_deductions,tbl_reversed_deduction_paid "+
"set tbl_employees.emp_id=@newemp_id,tbl_emp_additional_info.emp_id=@newemp_id,tbl_allocated_deductions.
[code]...
I've also tried removing all the other "and" operators but still no luck.It doesn't throw in exception yet it doesn't update my tables column values.
View 14 Replies
View Related
Jul 1, 2013
I've got two classes, which are both derived from the same two base classes. Here's a representation of the actual code:
Code: #include <vector>
class BaseClassA {
};
class BaseClassB {
};
class TestClassX
: public BaseClassA,
public BaseClassB
[code].....
Basically, I'd like to know if it is possible to cast directly from a BaseClassA pointer to a BaseClassB pointer, without casting to the child class first.
View 10 Replies
View Related
Nov 24, 2014
I'm learning OpenGL using the C API and some of the functions' argument types have proven a bit challenging to me.
One example is the function Code: glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length); It resides in foo() which receives a vector "data" from elsewhere Code: void foo(std::vector<std::pair<GLenum, GLchar const*>> const& data); To pass the pair's second element to glShaderSource's third argument, I do the following:
Code:
GLchar const* const source[] = {data[0].second};
glShaderSource(..., ..., source, ...);
Now I have two questions regarding this:
1. Can I initialize a char const** via initialization list, the way I do a char const*?
Code:
// this works
std::vector<std::pair<GLenum, GLchar const*>> const shader_sources = {
{GL_VERTEX_SHADER, "sourcecode"},
{GL_FRAGMENT_SHADER, "sourcecode"}
};
// but is this possible?
std::vector<std::pair<GLenum, GLchar const**>> = { ??? };
2. Is there an alternative to creating a temporary GLchar**, even though that's specifically what the function wants?
View 2 Replies
View Related
Jan 20, 2014
I have a C program. Within it, I would like to embed either a file or a pre-assigned variable. I would prefer a method that is platform independent.
I am using the data type "RSA" from <openssl/rsa.h>. I have a key file in PEM format, but I would like to embed an RSA object in the program instead. I tried creating a char array and then casting the pointer, but that caused some sort of illegal casting issue. I tried using memcpy but I haven't been able to get it working that way. What is the best way of going about this? Is it possible to read a file directly from a memory buffer?
View 1 Replies
View Related