|
A number of questions:
1. What is _Context? clearly it is a custom class of some sort.
2. What does ApplyPropertyChanges do? that would be the code to show us.
3. If you try to update the Navigation property what error occurs?
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
1 & 2 are self explanatory if you know about Enitity Framework.
3 is ridiculous to ask if you don't know anything about 1 & 2.
I know the language. I've read a book. - _Madmatt
modified on Monday, November 16, 2009 7:27 AM
|
|
|
|
|
Thanks very much.
1. _context is System.Data.Objects.ObjectContext
2. ApplyPropertyChanges(string entitySetName, object changed) is the method of System.Data.Objects.ObjectContext
In my tests, the ApplyPropertyChanges method don't do its job for EntityReferences.
finally, I modify the code as following, It work fine.
public void UpdateProduct(Product updated, Category category, Model model)
{
Product original = _context.Product.FirstOrDefault(a => a.ProductID == updated.ProductID);
if (category != null && original.ProductCategory.CategoryId != category.CategoryId) original.ProductCategory = category;
if (model != null && original.ProductModel.ModelID != model.ModelID) original.ProductModel = model;
_context.Attach(original);
_context.ApplyPropertyChanges("Product", updated);
_context.SaveChanges();
}
modified on Monday, November 16, 2009 11:18 PM
|
|
|
|
|
Please use pre tags when posting code. I think you meant to reply to the other poster.
I know the language. I've read a book. - _Madmatt
modified on Monday, November 16, 2009 10:06 AM
|
|
|
|
|
Try having a look here[^]. Look for ApplyReferencePropertyChanges
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,How do I Export data from SQL Server to Excel by vb.net codes
|
|
|
|
|
A few seconds of search would have given you: [This]
|
|
|
|
|
1>connect to the server (sqlserver)
2>go to the database
3>right click to the database the task->export..
4>wizard will pop up
5>then go throught that wizard.....
|
|
|
|
|
hi i'm creating a program with two listview.
one get the "Group" and other get the "members of the selected Group"
but i have problem
only get the first member .
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
lstestacoes.Clear()
lstestacoes.View = View.LargeIcon
Try
If con.State = ConnectionState.Open Then con.Close()
con.Open()
Dim ind As Integer
Dim temp As String
For Each item As ListViewItem In ListView1.SelectedItems
If item.Selected = True Then
temp = item.SubItems(0).Text
itemSelected = item.SubItems(0).Text
Dim cmd As New OleDbCommand("select * from Estacao WHERE idGrupo= '" & temp & "'", con)
Dim drdr As OleDbDataReader
drdr = cmd.ExecuteReader
If drdr.Read() Then
ind = ind + 1
Dim i As New ListViewItem(ind)
i.Text = drdr.Item("Nome")
i.ImageIndex = 0
lstestacoes.Items.AddRange(New ListViewItem() {i})
Else
cmd.Cancel()
con.Close()
End If
End If
Next item
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
My database have two tables "Grupo" and "Estacoes"
obs : "Grupo" is the Group and "Estacoes" is the members
at the group i have = id,name
and in Estacoes i have = id,name,ip,descricao,grupo
how can i set to get all members ?
SORRY LONG TIME I'M NOT SPEAK ENGLISH
modified on Friday, November 13, 2009 6:09 PM
|
|
|
|
|
Hi,
1.
please use PRE tags instead of CODE tags to make things readable.
You can still edit your original message...
2.
I doubt Dim i As New ListViewItem(ind) is correct.
Try Dim i As New ListViewItem()
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
ok i will use.
but in the data base the colunn idGrupo is "Lab1" for exemple not number.
in group the items are inserted correctly but foe members no, why ?
the problem is when the code are debugin only get one member "the first"
is because i'm searching for string at database for example "Lab1" in colunn "idGrupo" ?
i don't know why he get only the first provabily the code is wrong ^^"
|
|
|
|
|
I think this line is the culprit
If item.Selected = True Then
Remove this If condition and try again.
|
|
|
|
|
i'm used other code to resolve this problem .
i'll post where for know how code i used.
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
lstestacoes.Clear()
lstestacoes.View = View.LargeIcon
Try
If con.State = ConnectionState.Open Then con.Close()
lstestacoes.Clear()
lstestacoes.View = View.LargeIcon
Dim ind As Integer
Dim temp As String
For Each item As ListViewItem In ListView1.SelectedItems
If item.Selected = True Then
temp = item.SubItems(0).Text
Dim adptr As New OleDbDataAdapter("select * from Estacao WHERE Grupo= '" & temp & "'", con)
Dim ds As New DataSet
Dim dr As DataRow
Dim dt As New DataTable
Dim imageListSmall As New ImageList()
Dim imageListLarge As New ImageList()
Dim grupoquant As Integer
Try
adptr.Fill(ds, "Grupo")
dt = ds.Tables(0)
For Each dr In dt.Rows
ind = ind + 1
Dim i As New ListViewItem(ind)
i.Text = dr.Item("Nome")
i.ImageIndex = 0
lstestacoes.Items.AddRange(New ListViewItem() {i})
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
end sub
|
|
|
|
|
Dear Sir
I have many forms in my vb.net projects
I have to write(copy) all connection codes to connect DB for each form
Is any better way???? for example a class or a dll to help me ????
Generally I want another method (class or dll file) to call for loading of my forms...
Sorry about my bad english...
Thanks
|
|
|
|
|
yu can create a class with this code:
Public con As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & My.Settings.dbBase.ToString & ";Jet OLEDB:Database Password=" & My.Settings.dbBasePass.ToString & ";")
where i use a settings option to store the informations converted to string :
data base : My.Settings.dbBase.ToString
password : My.Settings.dbBasePass.ToString
i hope help you ^^
my english is not good too ^^"
|
|
|
|
|
Standard object orientated multitier design patterns help here. Been around for years.
You need to abstract all your dataAccess code (creating the connection, calling SQL etc.) into a separate DataAccess class. Then from any form in the application just call your dataaccess class.
MSDN tutorial 1: Creating a Data Access Layer[^] should give you a good start point.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
I should add that althought the MSDN articl I posted about is for ASP.Net Web Applications the DataAccess logic and code is identical for Windows Forms applications.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Hi,
I am using below code to call webservice from .aspx page through javascript on my server(window 2003). i am facing Permission denied error while calling below code from client machine. can anybody help me out. tanx in advance.This application is working fine on local.
function XmlhttpCall(objXML,serviceName)
{
try
{
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
var xmlHttpGo = xmlHttp;
var str = "http://192.168.0.1/mywebservice/MathWerService.asmx+serviceName;
//note = ip address is the ip address of server.
//service name is the name of service use in webservice
xmlHttpGo.open("POST", str, false);
xmlHttpGo.SetRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttpGo.send('xmlLogin=' + objXML.xml);
var xmlString1 = xmlHttpGo.responseXML.text;
return xmlString1;
}
catch(e)
{
return (e.Message + "--> XmlhttpCall");
}
}
Prabhat
no comment
|
|
|
|
|
i want to develop a windows application which work online and connect with remote sql/oracle database server through tcp/ip sockets in .net.
Avneesh Sharma
Software Developer : INFO International
City-Rishikesh-249201
Dist.-Dehradun
State-Uttarakhand
India
|
|
|
|
|
Just about every beginners book covers this.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for this information.
i know socket connection but my problem is how can i connect database through internet connection.
Avneesh Sharma
Software Developer : INFO International
City-Rishikesh-249201
Dist.-Dehradun
State-Uttarakhand
India
|
|
|
|
|
In your code, it's no different than if the database server was sitting right next to you.
You have to know how to configure your network and the network the server is sitting in in order to do this. Since there are sooooo many options, services and devices that can be between your client machine and the server, it's pretty much impossible to tell you what you have to do to set this up.
|
|
|
|
|
i'm trying some tutorials about .net remoting. in my machine the framework v1.0.3705,v1.1.4322,v2.0.50727,v3.0 and v3.5 are available.but the problem is only v2.0.50727
contains the config folder and it contains the machine.config file. in that file also the channel tag is not there, any one know why?
|
|
|
|
|
I haven't had the need to do it for a while, but I need to generate help docs from the XML comments in the source code. I've used NDoc in the past but I see that it hasn't been updated since 2005. Anyone have recommendations for alternatives?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sandcastle for .NET 2 onwards, or Doxygen.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|