|
In a C# 2010 application I would like to be able to use linq instead of sql to update from to 1 to 6 specific columns in a table that is stored in sql server 2008 r2 database. I am asking that question since I know linq is the preferred method over using sql.
I do know what the key to the table is.
Thus can use tell me how to acdcomplish this goal?
|
|
|
|
|
sc steinhayse wrote: linq is the preferred method over using sql.
Only if you're no good at writing SQL -- otherwise writing SQL will always be superior.
sc steinhayse wrote: tell me how to acdcomplish this goal
I have no idea; I don't use Linq.
|
|
|
|
|
If you use Linq to SQL query, you can use:
var myQuery =
from persons in myDataContext.LastPersons
where persons.LastName.StartsWith("Co")
select persons;
foreach (clsPerson currentPerson in myQuery)
{
currentPerson.LastUpdate = DateTime.Now;
}
try
{
myDataContext.SubmitChanges();
MessageBox.Show("Operation successfully");
}
catch (Exeption ex)
{
MessageBox.Show(ex.Message);
}
search DataContext reference
|
|
|
|
|
|
Usually the key column will be updated automatically, To use Linq or other tool, you should have primary and foreign key properly defined for the Table.
Linq will be the simplest and easy way, you will be updating as you update the collection like how you update collection in C#, it will updates DB Automatically
|
|
|
|
|
Hi,
i have 3 tables in my sql database:
The tables are:
1.Items table
fields=Id,Barcodes,ItemDescription,QtyAvailable,UserI
D,BranchID,CostPrice,SalesPrice
=====================================================
2.Sales table
fields=Id,SalesDate,QtySales,ItemID,CustomerID
=====================================================
3.customer table
fields=ID,Fname,Lname,Address,Phone#
=====================================================
how do i link all these tables together in asp.net
webform such that with 1 combo box, i can select
customer name and every details i want in the form
and the second combo box will select Item ID and all
corresponding info of the product(like Quantity
Available, Sales price, etc) and 2 blank columns for
recording quantity sold and date sold?
I have created customer form using LINQ to sql, now i
want intergrate sales/items tables into it such that
when i select a particular customer, i should be able
to select items(2 or more items) he/she buys and
manually enter quantity sold while the price is
inserted automatically from item table and current
date is inserted in the form automatically. Please
how do i achieve this?
|
|
|
|
|
Johnmc071 wrote: asp.net
You might want to ask in the ASP.NET forum.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Hi all,
As said in the message subject, I'm looking for a rules-based expert system proven enough to be integrated in a commercial product. I have used JBoss Drools (Java) in the past and at first I have thought to use Dools.NET, but there [^] I found a message from Mark Proctor assuring that the project has been abandoned a few years ago, and the truth is that it scares me a little.
Consequently, an option is to connect JBoss Drools (Java) with the C# project somehow, but previously I prefer to ask if someone have faced such situation. ¿Is there any other proven expert system engine available over C#?
Thanks in advance.
modified 22-Jun-12 7:44am.
|
|
|
|
|
You might want to look into NxBRE.
|
|
|
|
|
Thank you very much, it seems really interesting. Nevertheless, if anyone has any other suggestion, I'm all ears.
Thank you again.
|
|
|
|
|
Hello,
I m woking on a web application that logins on another website and then downloads some files from that site just on a click of a button.
I have already implemented the logic to login on that website and am also able to see the protected page of that site.
Now that website is returning an HTML code that has the filename i want to download under <script> tag
<script>PrintFileURL("13572_BranchInformationReport_2012-05-22.zip","13572_BranchInformationReport_2012-05-22.zip",0,"184601","May 22 1:30","/icons/default.gif")</script>
the method called is
<i>function PrintFileURL(uri, name, dirFlag, filesize, time, icon)
{
var color
var bgcolor
if(!(name.length>2 && name.charAt(name.length-1)=="e" && name.charAt(name.length-2)==".")) {
if (lineColor)
{
bgcolor="EEEEEE"
lineColor=false
}
else
{
bgcolor="FFFFFF"
lineColor=true
}
document.write("<TR bgcolor=" + bgcolor + ">");
if (dirFlag)
{
document.write("<td nowrap><img src='../" + icon + "'><a href='" + uri +
"/?T'> " + name + "</a></td>");
document.write("<td> </td>");
document.write("<td> </td>");
document.write("<td> </td>");
}
else
{
document.write("<td nowrap><img src='" + icon + "'><a href='" + uri +
"'> " + name + "</a></td>");
document.write("<td><font face=Arial size=2>" + filesize +
"</font></td>");
document.write("<td><font face=Arial size=2>" + time +
"</font></td>");
document.write("<td> </td>");
}
document.write("</TR>");
}
}</i>
I am totally stuck here. Can someone help.
Thanks in advance
Regards,
Akhil
-- modified 22-Jun-12 6:05am.
|
|
|
|
|
|
Hi
I am new to C# and am still learning I am trying to merge data from iether 1 or multiple coloumns of a data file to x & y coordinates in a pdf file ive downloaded itextsharp but am not sure where best to begin any suggestion appreciated also want to call in font downloaded off internet.
Thanks & regards
|
|
|
|
|
Member 9155359 wrote: but am not sure where best to begin
Somewhere like this[^], where you should find some useful samples and tutorials.
|
|
|
|
|
I am trying to annotate an existing pdf document, however, i can only open the document readonly mode, it doesn't edit or annotate it, on the other hand, i can only create a pdf and overwrite my version. What is the problem?
|
|
|
|
|
candogu wrote: What is the problem?
Impossible to say without a lot more information.
|
|
|
|
|
If it's only one PDF that is like this, then it means it's been saved as a read only PDF. If it's a problem with all external PDFs, then it's your code that's at fault.
|
|
|
|
|
i want to display large content i.e data may be 50 to 60 mb for example bible in desktop application.how i can do that?
|
|
|
|
|
Like it says in "how to ask a question", choose THE correct forum. THE means one, not two or more.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
In a C# 2010 application, I have a string value that looks like the following:
"http://localhost:99/test/TestHome.aspx". I only want to obtain the part of the string that is "TestHome.aspx".
I have tried lots of string functions to obtain the "TestHome.aspx" part of the string with no success yet.
Thus can you tell me how to obtain the part of the string I am trying to access?
|
|
|
|
|
There are many ways you could accomplish this. You could use a regular expression (a sledgehammer to crack a nut). You could use string.LastIndexOf to find the last / and then do a Substring based off this, or you could do a string.Split and take the last item out of the array.
|
|
|
|
|
Use System.IO.Path.GetFileName("http://localhost:99/test/TestHome.aspx")
|
|
|
|
|
Good one! My first impression was "that's a URL, not a path. It'll never work." Then I tried it.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
GetFileName is a good choice, but it does have the limitation of that it is actually doing more than is necessary to solve this particular problem. Why is that you ask? Well, when we deconstruct the method, it actually does the following:
public static string GetFileName(string path)
{
if (path != null)
{
CheckInvalidPathChars(path);
int length = path.Length;
int num2 = length;
while (--num2 >= 0)
{
char ch = path[num2];
if (((ch == DirectorySeparatorChar) || (ch == AltDirectorySeparatorChar)) || (ch == VolumeSeparatorChar))
{
return path.Substring(num2 + 1, (length - num2) - 1);
}
}
}
return path;
} As you can see, right at the top of the method, it's calling CheckInvalidPathChars to determine whether or not the path is valid. However, this is just a minor point - yours is a perfectly good solution, hence my 5.
|
|
|
|
|
Don't worry about anything, single one line code will solve problem,
i have complete program for you:
String s = "http://localhost:99/test/TestHome.aspx";
s = Path.GetFileName(s.Replace("/", "\\"));
Console.WriteLine(s);
Console.ReadKey();
|
|
|
|