|
<datagrid>.DataSource = Nothing
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Hello !
I'm using vb.net 2017 and Entity Framework 6.
Is there any way to update only one table in model from database ?
I try to right click on model.edmx and choose Update model from database , but this way update and recreate the entire model.
I've tried also to delete only the table that I've changed on database , and after I choose Update model from database and after on ADD I select only this table , but after the entire model is recreated.
How can I do ?
|
|
|
|
|
I have a ListView with OwnerDraw enabled and I am processing just DrawItem().
I am using LargeImageList with 48 x 48 ImageSize and View = MediumIcons.
When I rename an item to cause the text to wrap and thereby causing the height
of the item to increase, every thing is ok while the item is selected; ie. Has Focus.
When I select a different item and the renamed item loses focus, e.bounds reports
a reduced height which causes misalignment of text.
Note: This does not occur when wrapping results with 2 lines. But does occur when there are 3 lines.
What am I missing?
Thank you
Private Sub OpenFileDialogListView_DrawItem(ByVal sender As Object, ByVal e As DrawListViewItemEventArgs) Handles MyBase.DrawItem
' Start of function. No preceding code.
' If I break here when item is selected, e.bounds.height = 94.
' When not selected, e.bounds.height = 81.
e.DrawBackground()
End Sub
-- modified 28-May-19 12:24pm.
|
|
|
|
|
I have a similar app written in C++. When the view is in "Large Icon" mode then the text is restricted to two lines (with a trailing ellipsis). However, when an item is focused it shows all three lines. Thus the height of the item varies between focused and unfocused.
|
|
|
|
|
You beat me. I just created a test app in Mfc myself and found that out.
I was confused because Explorer somehow displays 3 lines. Must be custom control
because Spy does not show what kind of control it is.
Thanks a for your help.
|
|
|
|
|
Hi,
I'm used to make Excel add-ins with vba (xlam files). There I can place my button wherever I want. New or old tab, new or old group. Now I have made an vb.net add-in and I want to place my button into a specific group. I already managed to place it into the right tab and after the group but I want it into that group. Can this been done? if yes how?
Thanks Jan
|
|
|
|
|
|
I'm using entity Framework 6.
On my database I have these tables :
MasterTable ( Id , name)
Child1 ( ID , name , vl1 , Master_ID)
Child2 ( ID , name , vl2 , MasterID )
Child3 (ID , name , vl3 , Master_ID )
Child3Itm ( ID , name , Child3_ID)
For a given `MasterTable` item, I want to load with a single Query from database:
- All `Child1` where `vl1 > 5`
- All `Child2` where `vl2 > 6`
- All `Child3` where `vl3 > 7`
And in each `Child3` to load all of the `Child3Itm` content.
I'm using this query:
Dim lst = (From t In context.MasterTable.Where(Function(t1) t1.id = 7)
Select New With {
t,
.chld1 = t.child1s.Where(Function(t21) t21.vl1 >5),
.chld2 = t.child2s.Where(Function(t31) t31.vl2>6 ),
.chld3 = t.child3s.Where(Function(t41) t41.vl3>7).Select(Function(t411) t411.Child3Itms)
}).ToList
The problem is that no `Child3` are selected. All others are OK.
What can i do?
Thanks in advance!
modified 16-May-19 13:35pm.
|
|
|
|
|
How about:
.chld3 = t.child3s.AsQueryable().Include(Function(t411) t411.Child3Itms).Where(Function(t41) t41.vl3 > 7)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Now i'm getting an error :
System.NotSupportedException: 'LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[Myprog.Child3] Include[child3,ICollection`1](System.Linq.IQueryable`1[Myprog.Child3], System.Linq.Expressions.Expression`1[System.Func`2[Myprog.Child3,System.Collections.Generic.ICollection`1[Myprog.Child3itm]]])' method, and this method cannot be translated into a store expression.'
|
|
|
|
|
I've found 2 solutions that are working. Can someone tell me which is better ?
Solution 1
Dim lst = (From t In context.MasterTable.Where(Function(t1) t1.id = 7)
Select New With {
t,
.chld1 = t.child1s.Where(Function(t21) t21.vl1 >5),
.chld2 = t.child2s.Where(Function(t31) t31.vl2>6 ),
.chld3 = t.child3s.Where(Function(t41) t41.vl3>7),
.chld3itms = t.child3s.Where(Function(t51) t51.vl3>7).Select(Function(t511) t511.Child3Itms)
}).ToList
Solution 2
Dim lst = (From t In context.MasterTable.Where(Function(t1) t1.id = 7)
Select New With {
t,
.chld1 = t.child1s.Where(Function(t21) t21.vl1 >5),
.chld2 = t.child2s.Where(Function(t31) t31.vl2>6 ),
.chld3 = (From t2 in t.child3s.Where(Function(t41) t41.vl3>7)
Select New With {
t2,
.chld3it=t2.Child3Itms
})
}).ToList
|
|
|
|
|
Neither, they do the exact same thing. It's up to your preference.
|
|
|
|
|
I mean better for performance and the complexity of sql query that is generated in each case..
|
|
|
|
|
Like I said, they both do the exact same thing and generate the exact same SQL.
|
|
|
|
|
I wrote code to fetch a user information from ldap active directory in vb.net . But I'm having some difficulty regarding System.DirectoryServices DirectoryEntry method . It throws error like Microsoft VBScript runtime error '800a01f4' Variable is undefined: 'DirectoryEntry' . Please help
|
|
|
|
|
Maybe it is because you have not declared the variable. But unless you show us the actual code we have no way of knowing. And why are you trying to run VB.NET code as VBScript?
|
|
|
|
|
Stop. You're trying to use VB.NET code in the VBScript interpreter and that's just not going to work. The two languages are very different.
|
|
|
|
|
System.DirectoryServices.DirectoryEntry is a .NET Framework class.
You are using VBScript.
VBScript cannot use .NET Framework classes unless you create and register a COM-callable wrapper for them.
COM Callable Wrapper | Microsoft Docs[^]
VBScript has its own method for reading Active Directory:
Retrieve AD info for one user using VBScript[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello ,
Now I'm getting error like ADODB.Connection error '80040e21'
Read-only property value was not set.
My Code
cBase = "<ldap: dc="***,DC=***,DC=****,DC=****">"
cAttName = "samAccountName" 'FirstName.LastName
cObjUser = strUserName
cFilter = "(&(OU=***))"
cFilter = "(&(OU=***))"
cFilter = "(&(OU=***))"
cFilter = "(&(cn=***))"
cAttributes = "distinguishedName,name,description,gcbuildingnameenglish"
oQuery = cBase & ";" & cFilter & ";" & cAttributes & ";subtree"
Set objConnectionAD = CreateObject("ADODB.Connection")
objConnectionAD.Open "Provider=ADsDSOObject;"
Set objCommandAD = CreateObject("ADODB.Command")
objConnectionAD.Properties("User ID") = "****"
objConnectionAD.Properties("Password")= "*****"
objCommandAD.ActiveConnection = objConnectionAD
objCommandAD.CommandText = oQuery
Set objRecordSetAD = objCommandAD.Execute
if objRecordSetAD.RecordCount > 0 then
Set objUserAD = GetObject("LDAP://" & objRecordSetAD.Fields("distinguishedName"))
Select Case strADfield
Case "mail"
getADinfo = objUserAD.mail
End Select
else
getADinfo = ""
end if
'On Error Resume Next
Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2
Any solution for this . I'm getting error in userid and password .
|
|
|
|
|
Hey guys, I hope that somebody here can help me ...
I have on my SQL SERVER 2014 DATABASE a table with a field Datetime Null
My date appears like 2019-05-15 00:00:00.000
When I filter with a stored procedure works fine using the params:
cmd = New SqlCommand("SELECT vta.datesale FROM Sales WHERE vta.datesale = @mydate", myConn)
cmd.Parameters.AddWithValue("@mydate", Now.Date())
but my trouble is when:
1.- I use the same cmd
cmd = New SqlCommand("SELECT vta.datesale FROM Sales WHERE vta.datesale = @mydate", myConn)
2.- I have a DateTimePicker and I choose any day
3.- My code in the event ValueChanged() of my DateTimePicker is:
a.- The same cmd in the number 1
b.- then ...
cmd.Parameters.AddWithValue("@mydate", dtMyDate.Text)
dtMyDate = Control DateTimePicker.
I'm receiving this error:
"Conversion of a varchar data type to a datetime data type resulted in an out-of-range value"
Somebody can help me?.
Thanks in advance and excuse my grammar; I'm not a native speaker and I don't like to use translators.
Javier.-
|
|
|
|
|
Member 11220465 wrote:
"Conversion of a varchar data type to a datetime data type resulted in an out-of-range value" Means the runtime tries to convert your datetime from a varchar, or string. You don't want that, if you're supplying DateTime, it should be interpreted as such. Show us your code, we'll be gentle.
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.
|
|
|
|
|
Thanks a lot for your time, Eddy ....
I'll share you (in Spanish) my screenshots
1.- Data storaged on my table Ventas
https://ibb.co/TBmHSm6
You can see: yyyy-mm-dd hh:mm:ss.sss .... The field is DateTime (accepting NULLS, before with no accept NULLs I had the same error).
2.- Code from the event ValueChanged() of my control DateTimePicker (dtFecha)...
https://ibb.co/pbsqnqP
3.- Error that I received when I try to access a day from my DateTimePicker that has data.
https://ibb.co/pQYTfQF
Thanks a lot, gentleman or any other bud that can help me. And again, excuse my grammar mistakes; I'm not a native speaker.
Thanks guys,
Javier.-
|
|
|
|
|
Member 11220465 wrote: And again, excuse my grammar mistakes; I'm not a native speaker. Your English is fine.
You are fetching the .Text property of the DataTimePicker , which returns a string. Then the code will try to turn that (locally formatted) string and convert it back to a DateTime , which then fails.
Try dtFecha.Value instead, it should give you a DateTime value, not a formatted string.
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.
|
|
|
|
|
You're awesome
Thanks a lot, Eddy .... You gave me the real clue in here ...
"Then the code will try to turn that (locally formatted) string and convert it back to a DateTime, which then fails."
When I read that, I used a MsgBox (to test) and you were right, dude
I tried with dtFecha.Value but failed .... but I picked another way: CDate(dtFecha.Text) and it's working fine
You guy, you're the real MVP hahaha
Thanks a lot, bud. A great hug and my best wishes for you and your family, my man
|
|
|
|
|
Glad I could help
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.
|
|
|
|