|
Hello !
I have a binding source to entity :
MyBindingsource.datasource=(From t in context.Mytable Select t.id , t.vl1 , t.vl2).Tolist
Now , I try to change a value like this :
Mybindingsource.Current.vl1=25
I get a n error :
An unhandled exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll
Additional information: Property 'vl1' is ReadOnly.
Why I get this error ? What can I do ?
Thank you !
|
|
|
|
|
vl1 is a property in a class. It does not have a set accessor, i.e. your property looks something like
public int vl1
{
get { return ...; }
}
insetad of
public int vl1
{
get { return ...; }
set { ...; }
}
|
|
|
|
|
Why does not have a set ?
Because , if I try the following code everything works ok :
MyBindingsource.datas
ource=(From t in context.Mytable Select t).Tolist
Why this :
MyBindingsource.datasource=(From t in context.Mytable Select t.id , t.vl1 , t.vl2).Tolist doesn't work ?
Thank you !
|
|
|
|
|
dilkonika wrote: Because , if I try the following code everything works ok : That's different code; the setter isn't used there. The code below, as you posted, would raise that exception - if it is a read-only property.
Mybindingsource.Current.vl1=25
dilkonika wrote: MyBindingsource.datasource=(From t in context.Mytable Select t.id , t.vl1 , t.vl2).Tolist Does it throw the SAME exception? I don't see it assigning anything to vl1 and doubt that it will throw the same error.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
If I use
MyBindingsource.datasource=(From t in context.Mytable Select t).Tolist
and after :
Mybindingsource.Current.vl1=25
everything is ok.
|
|
|
|
|
dilkonika wrote:
If I use
MyBindingsource.datasource=(From t in context.Mytable Select t).Tolist
and after :
Mybindingsource.Current.vl1=25 everything is ok.
Is it the same Mytable? Apparently this one has a field for vl1 that is assignable - as in, not a view.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
It's "something" in the EF framework. The first query is a simple one, and it may generate a decent update-statement for it- while that may be a bit harder for the second query.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am writing a code for my CIS-115 class. I have all of the information that I need in it (I think!), but I cannot get ALL of my calculations to execute correctly; only 2 of 5 come out right. Am I allowed to post it here to get help?
|
|
|
|
|
Yes, but don't ask for anyone to write your code for you. That's the restriction.
|
|
|
|
|
You will need to design an application that will receive the customer type and its units of utility used for the billing duration. The application will calculate and display the cost per unit based on the customer type and the total charges for that billing cycle. Calculate the charges using the following data.
Customer Type Units Consumed Cost per unit ($)
Commercial <= 1,000 $0.50 per unit
Commercial 1,000 < $0.50 per unit
Industrial < 800 $0.65 per unit
Industrial 800 <= 2,000 $0.55 per unit
Industrial 2,000 < $0.50 per unit
Residential < 500 $0.85 per unit
Residential 500 <= $0.75 per unit
Make sure that the units consumed entered is a positive number and the customer Type is valid; otherwise your program should display an error message and ask for the data to be entered again until the user enters valid data. Test your algorithm with the following three sets of data.
Test case 1: Units used of 799, Customer Type is Industrial
Test case 2: Units used 500, Customer Type is Residential
Test case 3: Units used 800, Customer Type is Industrial
Test case 4: Units used 1000, Customer Type is Commercial
Test case 5: Units used 499, Customer Type is Residential
|
|
|
|
|
Sub Main()
Dim customerType As String
Dim unitsConsumed As Decimal = 0
Dim costPerUnit As Decimal = 0
Dim totalCharges As Decimal = 0
Do
Console.Write("Enter the customer type as commercial, industrial, or residential: ")
customerType = Console.ReadLine()
While customerType <> "commercial" And customerType <> "industrial" And customerType <> "residential"
Console.WriteLine("ERROR - Enter commerical, industrial, or residential.")
Console.Write("Enter the customer type as commercial, industrial, or residential: ")
customerType = Console.ReadLine()
End While
Console.Write("Enter the units consumed: ")
unitsConsumed = Console.ReadLine()
While unitsConsumed < 0
Console.WriteLine("ERROR - Please enter a value greater than zero.")
Console.Write("Enter the units consumed. ")
unitsConsumed = Console.ReadLine()
End While
If unitsConsumed <= 1000 Then
costPerUnit = 0.5
If unitsConsumed < 1000 Then
costPerUnit = 0.5
If unitsConsumed < 800 Then
costPerUnit = 0.65
If (unitsConsumed > 800) And (unitsConsumed <= 2000) Then
costPerUnit = 0.55
If unitsConsumed > 2000 Then
costPerUnit = 0.5
If unitsConsumed < 500 Then
costPerUnit = 0.85
If unitsConsumed >= 500 Then
costPerUnit = 0.75
End If
End If
End If
End If
End If
End If
End If
totalCharges = unitsConsumed * costPerUnit
Console.WriteLine("The total charges are: " & totalCharges)
Console.ReadLine()
Loop
End Sub
|
|
|
|
|
This is the code that I have, but only Test Case 1 and 4 execute correctly. I have sat here for hours looking through my book and lectures, but I'm just blind to my problem. Thank you, in advance, if you are able to help me!
|
|
|
|
|
Look at your nested if statement 100 meets these criteria 1000, 1000, 800 500 so which value will be returned, the first of course.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Another day, another hint.
If x < 1000 Then
If x < 800 Then
If x > 2000 Then
End If
End If
End If Find me a number smaller than 1000, but larger than 2000.
There's another problem, take a look at the example-rules;
Member 10728667 wrote: Commercial <= 1,000 $0.50 per unit
Commercial 1,000 < $0.50 per unit If think the first price is for commercial stuff if you buy 1000 items or less, and the second price would be if you buy MORE than 1000 items. That's prolly what the position of the operator should imply. Back to the code;
If unitsConsumed <= 1000 Then
costPerUnit = 0.5
If unitsConsumed > 1000 Then
Now that I switched the operator to what it probably should be, does it help to diagnose the error?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The easy thing to do is put a breakpoint and then step through your code and you'll see exactly what is happening. It should be very easy to solve at that point.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have a devexpress Master-View gridcontrol , bound to Entity bindingsource. Programatically I update some records on bindingsource , but the Gridcontrol is not refreshed with new data. I have used the following methods : ( GridviewMaster - is Master View , GridviewChild - is Detail view )
GridControl1.RefreshDataSource()
GridControl1.MainView.RefreshData()
GridControl1.DefaultView.RefreshData()
GridViewMaster.RefreshData()
GridViewChild.RefreshData()
But without success.I know that the bindingsource is updated , but the Gridcontrol is not. Only when i close and open the form again the gridcontrol is updated.
What can I do ? ( without querying the database)
Thank you !
|
|
|
|
|
Hello !
Is there any free Twain for .NET that I can use on a Visual basic 2013 Application ?
Thank you !
|
|
|
|
|
|
Hi guys,
I have the following code that will send an email from Visual Basic project using data from an SQL row called "Email". It works fine. However, it appears it is only showing one email from SQL into the TextBox. Therefore, only sending it to one email address. I have two email addresses stored in the database for testing but only one of them get the email message.
Here is the code:
Dim con As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=FigClubs;Integrated Security=True;Pooling=False")
Dim cmd As SqlCommand = New SqlCommand("SELECT Email FROM Members", con)
con.Open()
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataTable As DataTable = New DataTable
myDA.Fill(myDataTable)
con.Close()
con = Nothing
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential(My.Settings.ClubEmail, My.Settings.EmailPassword)
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(TextBox4.Text)
e_mail.To.Add(EmailTextBox.Text)
e_mail.Subject = TextBox1.Text
e_mail.IsBodyHtml = False
e_mail.Body = TextBox2.Text
Smtp_Server.Send(e_mail)
MsgBox("Your email has been sent.")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
Me.Close()
Any help you can provide with this would be greatly appreciated.
Thanks,
Dan
|
|
|
|
|
Your Select statement extracts the Email fields from your database and fills your DataAdapter. How do the email addresses then get to EmailTextBox ?
|
|
|
|
|
Hi Richard,
I am using the Dataset to populate the EmailTextBox.
Cheers,
Dan
|
|
|
|
|
And what do you see in the textbox at the time you try to create the mail message? It would really help people to help you, if you provided complete details of what you see when you run your code.
|
|
|
|
|
Hi Richard,
Thanks for the reply.
I did mention in my original post that only one of the stored email addresses show in the TextBox.
So basically, when I run the code, only one of the two email addresses in the Database is showing in the EmailTextBox and not the two that are stored.
My plan is to show any amount of email addresses that are stored in the database to be entered into the EmailTextBox when the application is run.
Cheers,
Dan
|
|
|
|
|
OK, and how do you think we can guess why there is only one email address showing? We have no idea what the content of the Email field is, how you are binding from your DataAdapter to your EmailTextBox etc. As I said before, we really need all the information you have, we cannot see what is going on on your screen.
|
|
|
|