|
If you're working in VB, why did you post your question in the C# forum?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
To repeat myself; the way you load it is not a problem. The way you store it is; go read up on what a primary key is.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Dude, that's just a thing of beauty right there. Almost as good as a macro.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You will also need something like
CONVERT(int, SUBSTRING(F.[ID], PATINDEX('%[0-9]%', F.[ID]), etc))
as otherwise, 10, 11,..., 19, 100, ..., 199 etc will fall between 1 and 2 because you are still comparing as strings
|
|
|
|
|
John Simmons / outlaw programmer wrote: I actually got an 'F' for the assignment) for the content of the string
Using "youareafuckingidiot" as your content will do that.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well, the instructor did not provide the string (a curiosity because it would have made evaluating the output from code much easier since everyone would have to have the same count), so I wrote a paragraph about the diminishing hemlines in college girls' skirts during summer classes.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Can it be done; yes.
Should it be done; not at this time.
Really should fix the database design first.
1. You should have a Good Primary Key. UID in its current state is not.
2. Class should be normalized- put it into its own table and link it back via another Good Primary Key
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
Hi,
I have he following code which for the line "await GetSkorekortSkore(x.SkorekortID)" is giving the error message "the await operator can only be used within an async lambda expression. Consider marking this lambda expression with the async modifier".
Any suggestion of how to make it work ?
return (from s in _db.SkoreKort
from k in _db.Klub
from b in _db.Bane
where (s.SkorekortID == SkorekortID &&
s.BaneKlubID == k.KlubID &&
s.BaneID == b.BaneID)
select new {
s.SkorekortID,
k.DGUKlubNr,
s.SkoreDato,
s.SpillerHCP,
k.KlubNavn,
b.BaneNavn,
b.TeeNavn,
b.HerreDame,
b.BaneID,
k.KlubID
}).AsQueryable()
.Select(x => new SkorekortDetailViewModel {
SkorekortID = x.SkorekortID,
DGUKlubNr = x.DGUKlubNr,
SkoreDato = x.SkoreDato,
SpillerHCP = x.SpillerHCP,
KlubNavn = x.KlubNavn,
BaneNavn = x.BaneNavn,
TeeNavn = x.TeeNavn,
HerreDame = x.HerreDame,
SkoreListe = await GetSkorekortSkore(x.SkorekortID)
}).ToListAsync();
}
public async Task<List<SkorekortSkore>> GetSkorekortSkore(int SkorekortID)
{
return await (from s in _db.SkoreKortSkore
where s.SkorekortID == SkorekortID
select s).ToListAsync();
}
modified 22-Mar-18 4:00am.
|
|
|
|
|
You haven't included the method definition for the top LINQ statement but that message is telling you that that method also needs to be async.
This space for rent
|
|
|
|
|
This is how it looks:
namespace Golf.Components
{
public class SkorekortDetailViewComponent : ViewComponent
{
public readonly GolfContext _db;
public SkorekortDetailViewComponent(GolfContext context)
{
_db = context;
}
public async Task<IViewComponentResult> InvokeAsync(int SkorekortID)
{
var items = await GetItemsAsync(SkorekortID);
return View(items);
}
private async Task<List<SkorekortDetailViewModel>> GetItemsAsync(int SkorekortID)
{
return (from s in _db.SkoreKort
from k in _db.Klub
from b in _db.Bane
where (s.SkorekortID == SkorekortID &&
s.BaneKlubID == k.KlubID &&
s.BaneID == b.BaneID)
select new {
s.SkorekortID,
k.DGUKlubNr,
s.SkoreDato,
s.SpillerHCP,
k.KlubNavn,
b.BaneNavn,
b.TeeNavn,
b.HerreDame,
b.BaneID,
k.KlubID
}).AsQueryable()
.Select(x => new SkorekortDetailViewModel {
SkorekortID = x.SkorekortID,
DGUKlubNr = x.DGUKlubNr,
SkoreDato = x.SkoreDato,
SpillerHCP = x.SpillerHCP,
KlubNavn = x.KlubNavn,
BaneNavn = x.BaneNavn,
TeeNavn = x.TeeNavn,
HerreDame = x.HerreDame,
SkoreListe = await GetSkorekortSkore(x.SkorekortID)
}).ToListAsync();
}
public async Task<List<SkorekortSkore>> GetSkorekortSkore(int SkorekortID)
{
return await (from s in _db.SkoreKortSkore
where s.SkorekortID == SkorekortID
select s).ToListAsync();
}
|
|
|
|
|
Try
return await (from s in _db.SkoreKort You're attempting to return an async operation without actually specifying that it's async.
This space for rent
|
|
|
|
|
It didn't change the error, it is still the same.
The error message suggest to add async in front of x => new SkorekortDetailViewModel as
}).AsQueryable()
.Select(async x => new SkorekortDetailViewModel {
SkorekortID = x.SkorekortID,
DGUKlubNr = x.DGUKlubNr,
SkoreDato = x.SkoreDato,
SpillerHCP = x.SpillerHCP,
KlubNavn = x.KlubNavn,
BaneNavn = x.BaneNavn,
TeeNavn = x.TeeNavn,
HerreDame = x.HerreDame,
SkoreListe = await GetSkorekortSkore(x.SkorekortID),
HulListe = await GetHuller(x.BaneID),
BaneListe = await GetBane(x.KlubID)
}).ToListAsync();
but that just shows all the linq as in error.
|
|
|
|
|
Were any parts actually working?
I would classify this as "unmaintainable"; and getting it to actually run would be bad karma.
You need to start with (working) "sub queries" that can be combined to arrive at the desired result; and where intermediate results can be checked / dumped if needed.
(Even the "SQL query plan optimizer" needs help sometimes).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It works fine without the line "SkoreListe = await GetSkorekortSkore(x.SkorekortID)".
I'm not sure if it can work the way i thought it should work, so I have changed it to this instead which works:
private async Task<List<SkorekortDetailViewModel>> GetItemsAsync(int SkorekortID)
{
List<SkorekortDetailViewModel> skorekortdetail = await (from s in _db.SkoreKort
from k in _db.Klub
from b in _db.Bane
where (s.SkorekortID == SkorekortID &&
s.BaneKlubID == k.KlubID &&
s.BaneID == b.BaneID)
select new {
s.SkorekortID,
k.DGUKlubNr,
s.SkoreDato,
s.SpillerHCP,
k.KlubNavn,
b.BaneNavn,
b.TeeNavn,
b.HerreDame,
b.BaneID,
k.KlubID
}).AsQueryable()
.Select(x => new SkorekortDetailViewModel {
SkorekortID = x.SkorekortID,
DGUKlubNr = x.DGUKlubNr,
SkoreDato = x.SkoreDato,
SpillerHCP = x.SpillerHCP,
KlubNavn = x.KlubNavn,
BaneNavn = x.BaneNavn,
TeeNavn = x.TeeNavn,
HerreDame = x.HerreDame,
BaneID = x.BaneID,
KlubID = x.KlubID
}).ToListAsync();
foreach(var skorekort in skorekortdetail) {
skorekort.SkoreListe = await GetSkorekortSkoreAsync(skorekort.SkorekortID);
skorekort.HulListe = await GetHullerAsync(skorekort.BaneID);
skorekort.BaneListe = await GetBaneAsync(skorekort.KlubID);
}
return skorekortdetail;
}
|
|
|
|
|
hi
i need help to create temperature converter .
the user can write 10 value in Celsius using listbox.
then clicks converter button
and value of celsius in the listbox
converts to fahrenheit and to kelvin
then display results of fahrenheit and kelvin in two other listboxs
here is my initial code
|
|
|
|
|
what is working : so far i achieve to let user enter the value of celsius in the Celsiuslistbox for celsius by using add button
with code : celsiuslistbox.items.add(textbox.text)
//
Conversion from Celsius to Fahrenheit ,the program loops only one time
what is not working : conversion code can not go through data in the listbox and converts all values , rather it only converts the first value, then keep running
modified 22-Mar-18 0:57am.
|
|
|
|
|
Please post your code in the first post you made on this topic.
You need to create:
1. Methods to handle temperature conversion
2. a Method to convert a string, or a set of strings, to a floating point number(s) ... this method should handle potential bad data input
3. a user-interface for a user to enter multiple values
4. a user interface that lets the user specify whether input values are C or F
5. a Method, or Methods, to manage the ListBoxes: update them, etc.
We're here to help you, but, we are not going to write the code foe you.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
I am using visual studio 2017
windows form. app(net.framework)
this my code
private void FjernBTN_Click(object sender, EventArgs e) // clear btn
{
textBox1.Text = "";
FahrenheitListBox.Items.Clear();
KelvinlistBox.Items.Clear();
Celsiuslistbox.Items.Clear();
}
private void KonverterBTN_Click(object sender, EventArgs e)// converter button code
{
Celsiuslistbox.Items.Add(textBox1);
double temp_Celsius; // temperature i celsius
double temp_Fahrenheit;// temperature i fahrenheit
int count;
for ( count = 0; count <10; count++)
{
temp_Celsius = Celsiuslistbox.Items.Add(textBox1.Text);
}
do
{
temp_Celsius = Celsiuslistbox.Items.Add(textBox1.Text);
} while ( count <=10);
temp_Fahrenheit = (9.0 / 5.0) * temp_Celsius + 32;
FahrenheitListBox.Items.Add(temp_Fahrenheit);
|
|
|
|
|
Please edit your original post, and update it, rather than post more.
And, what is the problem now . What works, what does not work ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Quite a lot wrong with your code:
private void KonverterBTN_Click(object sender, EventArgs e)
{
Celsiuslistbox.Items.Add(textBox1);
double temp_Celsius;
double temp_Fahrenheit;
int count;
for ( count = 0; count <10; count++)
{
temp_Celsius = Celsiuslistbox.Items.Add(textBox1.Text);
}
do
{
temp_Celsius = Celsiuslistbox.Items.Add(textBox1.Text);
} while ( count <=10);
temp_Fahrenheit = (9.0 / 5.0) * temp_Celsius + 32;
FahrenheitListBox.Items.Add(temp_Fahrenheit);
|
|
|
|
|
If all the user does is enter "Celcius", then you can just make the F and K values "calculated columns" in a listbox / view / grid (Don't need "multiple listboxes").
More satisfying is creating a "temperature object" that can except a given value and scale and return a corresponding value in any other scale.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I am building a database application which require some security with biometric prints. How to add the function to find records after scanning the print via the biometric machine?
|
|
|
|
|
Start with the biometric reader manufacturer's website: they will normally have sample code which demonstrates a basic "how to use it" app. Once you have that working, it should be fairly obvious what you need to do to get your app version working.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In order to "find" something, you need "keys / data".
Find out what "data" is being captured (and stored) with the "biometric prints".
Find out if there are other data generation / collection options for the "biometric machine".
Document the old physical and old logical.
Then create your new logical and new physical models.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have an integerExponentiate() function that operates on two objects of like type, and relies only on the fact that the type implements the * operator and has an instance that represents the mathematical concept of a unit. I have several classes that meet those criteria, and would like it to be possible for integerExponentiate() to be called on instances of any of those classes. My first thought was to make integerExponentiate() a generic method that takes the unit and a delegate representing the multiplication operator as parameters, something like this:
delegate T multiplier<T>(T a, T b);
T integerExponentiate<T>(multiplier<T> m, T unit, T expBase, Integer exponent);
But I don't see a way to assign an operator to a delegate. Is there a way to do that directly, or do I have to wrap the operator in another function and use that? Or should I consider another approach entirely?
|
|
|
|
|