|
Hello !
I'm using vb.net 2017 and EF 6.
I have a bindingsource and also datagrid that is bound to this bindingsource.
I need a way to clear all the items from bindingsource to empty it , but without deleting from database.
I've tried
Bindingsource1.Datasource=Nothing.
But , after calling this , the datagrid still have all the bindingsource items.
|
|
|
|
|
You need to call the Refresh method to repaint the grid.
|
|
|
|
|
I've tried also
Bindingsource.Clear
Bindingsource.Clear Bindingsource.Clear ,
this is working , but does this remove also from database ( if I call savechanges for example ?)
|
|
|
|
|
You should not use savechanges unless you want the database updated.
|
|
|
|
|
ok , but Bindingsource.clear only remove items from bindingsource or also mark them for deletion from database ?
|
|
|
|
|
Sorry, I don't know the answer. You could study the documentation, or write a simple test program to try it out.
|
|
|
|
|
<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 .
|
|
|
|