|
Hi,
To retrieve multiple records using more than one table, you have to create your custom entity on Entity Framework Model. Follow the below steps:
1. Open Entity Framework Model file (*.edmx) in Visual studio
2. Right click on design pane and select "Add" -> "Entity"
3. One blank entity is created. Just add number of properties which you need to retrieve from the database (please check the property of each columns means data type, Nullable and Entity Key option)
4. After creating custom activity, Right click on design pane and select "Add" -> "Function Import".
5. In function import dialog box, select your stored procedure, Function name and select Return type as "Entities" and select custom entity from the drop down box. Click on OK button.
6. Now you have to call that function to retrieve data from the stored procedure. please find code below:
TestDBEntities1 testdb = new TestDBEntities1();<br />
var p = from d in testdb.GetOrderInfo() select d;<br />
MessageBox.Show(p.Count<OrderInformationEntity>().ToString());
Here TestDBEntities1 is my entity framework class and OrderInformationEntity is a custom entity.
You can find primary information of using Entity framework here.
Hardik Patel
Blog: DotNet Code GuruRegards,
Hardik Patel
|
|
|
|
|
I have a datagridview which is bound to a ms access database, through a dataset.
The user can click one record on the DGV, and open another window with all the data of the record, so that he can edit them,etc.
If he tries to sort the DGV by a column, let's say the date field and then tries to load a record the thing gets messed up.
It seems that whilst the DGV is sorted, the dataset is not equally "sorted".
That means that the user can try to load a specific record but instead he gets a completely different one.
Is there a solution to that ?
|
|
|
|
|
You need to either use a unique key to load the record into the new window, or sort your underlying dataset in the same way as the DGV when the column header is clicked. Bob
Ashfield Consultants Ltd
|
|
|
|
|
You need to either use a unique key to load the record into the new window, or sort your underlying dataset in the same way as the DGV when the column header is clicked.
There is already an ID field which is unique.
How do i sort the dataset ? That's the question in the first place.
|
|
|
|
|
Anyone guys ?
Any ideas ?
|
|
|
|
|
Hello everyone
I have a second form in my program that will keep all the setting for my app
i am having a hard time to get my controls to pull the vavlue from the text boxes that is in the second form
What is the easyest best way to do this ??
or is thare a better way then using a second form
Thanks
Bobmodified on Wednesday, February 17, 2010 3:18 PM
|
|
|
|
|
In the second form do something like this:
public string SomeSetting
{
get { someTextBox.Text ; }
}
Then in Form1:
string mySetting = Form2.SomeSetting ;
Do this for all your text boxes.
|
|
|
|
|
is that for vb 2008 it dont work
|
|
|
|
|
Sorry, that is C#, I don't know VB.
But if you look up Properties, that should get you started.
|
|
|
|
|
Thats cool thanks anyways
|
|
|
|
|
Public ReadOnly Property SomeSetting() As String
Get
Return SomeTextBox.Text
End Get
End Property
Dim mySetting as String = Form2.SomeSetting I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Hello Everyone,
I am looking into developing an extension for windows explorer that will add a kind of a virtual folder (which access files and directories through a web service) so that I can drag files from my desktop and deposit them on a server via a web service.
Any ideas on how I should proceed? I'd like to write this in either c# or vb.net.
Thanks!
|
|
|
|
|
seanwright wrote: I'd like to write this in either c# or vb.net.
Either will do
seanwright wrote: Any ideas on how I should proceed?
Buy a book for the language you have decided on, start with the easy examples and work up from there.Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks for the tip. However, I have been writing programs for several years, albeit rather simple ones. I am familiar with both languages.
I guess I should be more precise: what I really want to know is: what are the mechanisms involved with creating this type of application? How do I interface with windows explorer through .net? Can anyone direct me to some sample applications?
Thanks
|
|
|
|
|
Writing shell extensions in anything other than .NET 4.0 is highly recommended AGAINST.
If your entire experience is writing simple applications, a shell extension is going to be a major shock to you. Unless you have a very good working knowledge of COM and how to interop, you'll find this task very tough. For a sample of what you'd be getting into, read this[^].
seanwright wrote: so that I can drag files from my desktop and deposit them on a server via a web service.
A stand-alone application would allow you do this much easier than writing a shell extension, and you can write this in any lanugage you want.
|
|
|
|
|
Hi,
I use OdbcCommandBuilder.DeriveParameters to get a stored procedure parameters and fill them in with values. After that, I can access the command object to see all parameter's name and values. But when I fill the command with the data adapter I got the following error:
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'sSPName' expects parameter '@dteBeg', which was not supplied.
Code:
......
Dim cmdODBC As OdbcCommand = cnnODBC.CreateCommand()
cmdODBC.CommandTimeout = 300
cmdODBC.CommandType = CommandType.StoredProcedure
cmdODBC.CommandText = sSPName
cnnODBC.Open()
OdbcCommandBuilder.DeriveParameters(cmdODBC)
'Add values to parameters:
For i As Integer = 0 To cmdODBC.Parameters.Count - 1
......
Next
'Write out the parameter's name and value:
For Each parameter As OdbcParameter In cmdODBC.Parameters
response.write(parameter.ParameterName & "=" & parameter.Value)
Next
Dim adpODBC As New OdbcDataAdapter(cmdODBC)
adpODBC.Fill(ds, "Results") 'error appeal here.
......
Any helps are appreciated.
|
|
|
|
|
Hi,
I have a webapp on my filesystem that will eventually be deployed somewhere else where IIS obviously exists.
For now is it possible for my webapp to be made accessible from other systems on the LAN without hosting it on IIS? I mean can it be accessed from the development server itself? Something like:
http://10.x.x.x:port_number/MyWebAppName
I mean if I unblock the port in my firewall.
Kindly advise. I just need to get it up and running for a demo.
|
|
|
|
|
No, you must have a webserver of some kind. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
callousfantom wrote: from the development server itself
Cassini[^]?I are Troll
|
|
|
|
|
Hi,
As already pointed out, I was asking if it could be accessed from the development server itself. If not, can anyone guide me as to how to host it on IIS 7(windows vista). I have never hosted a website and am absolutely clueless.
My website is built in Visual Studio 2008. I Installed IIS 7. Added my website folder to inetpub/wwwroot, converted it to Application inside the "Default website" as I read in an article and even created an Application Pool and assigned it to my website but it keeps throwing different sorts of errors.PLEASE HELP. ITS URGENT! modified on Thursday, February 18, 2010 12:20 AM
|
|
|
|
|
I write to inquire if there is a way to develop java code using VSTS 2008? Is there a snapin or compatible app that would allow this? Much thanks for an informed opinion.
|
|
|
|
|
You can use VS to write the code but would not have any intellisense or other support, just as would get with notepad. You would also need a suitable compiler. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
To add to Mark's comments, I have done this for a small project, but without the intellisense and keyword highlighting it is not a great experience. I would much rather use Eclipse or NetBeans as both are geared to Java development, whereas Visual Studio is not. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi everyone,
I'm so confused right now I'm hardly sure where to begin. I've been tasked with writing an application using MSMQ. Basically, the app listens to a file folder, notices when a file's been added, sends a message to a router queue which then figures out what to do and sends a message to the appropriate processing queue. The router queue is receiving messages and it seems to be sending them on to the processing queue but the processing queue never receives the message. I've tried everything I can think of to get this working but cannot seem to do so and have no clue why not. No matter what I try, the processing queue never seems to receive the message that was sent to it.
Here's how the main program creates the router object (this is the one that works):
Private Sub StartRouter(ByVal myNode As XmlNode)
Try
m_RouterQueueName = myNode.Attributes("queuename").Value
TheRouter = New Router(m_RouterQueueName)
AddHandler TheRouter.onRouterStarted, AddressOf LogActivity
AddHandler TheRouter.onRouterMessageReceived, AddressOf LogActivity
AddHandler TheRouter.onRouterError, AddressOf LogError
Catch ex As Exception
LogError(ex)
End Try
End Sub
And here's the constructor in the router object:
Public Sub New(ByVal QueueName As String)
Try
m_QueueName = QueueName
StartListening()
Catch ex As Exception
RaiseEvent onRouterError(ex)
End Try
End Sub
You'll notice that it has a "start listening" routine. Here is that routine:
Private Sub StartListening()
myReceiveQueue = New MessageQueue(m_QueueName, QueueAccessMode.SendAndReceive, False, QueueAccessMode.SendAndReceive)
Try
'myReceiveQueue = New MessageQueue()
'myReceiveQueue.Path = m_QueueName
myReceiveQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(System.String)})
myReceiveQueue.UseJournalQueue = True
RaiseEvent onRouterStarted("Router listening to " & m_QueueName, "Started")
AddHandler myReceiveQueue.ReceiveCompleted, AddressOf MSMQ_ReceiveCompleted
myResult = myReceiveQueue.BeginReceive()
Catch ex As Exception
RaiseEvent onRouterError(ex)
End Try
End Sub
Now as to the processor (this is the part that's not working), here's how the calling program creates it:
Private Sub SpawnProcessors(ByVal myNode As XmlNode)
Try
For Each childnode As XmlNode In myNode
Dim myNewProcessor As New Processor(childnode)
AddHandler myNewProcessor.onProcessorStarted, AddressOf LogActivity
AddHandler myNewProcessor.onProcessorError, AddressOf LogError
AddHandler myNewProcessor.onProcessorMessageReceived, AddressOf LogActivity
ProcessorCollection.Add(myNewProcessor)
Next
' once we've been through all the processors and started them all, introduce this list to the router
TheRouter.IntroduceProceduresToRouter(ProcessorCollection)
Catch ex As Exception
LogError(ex)
End Try
End Sub
Since the router sends messages to the processors you'll see that I have a line in there that introduces the processes to the router. All this does is take the collection of processors and "copy" it to the router so the router can know what's going on (maybe the problem is in doing this???):
Public Sub IntroduceProceduresToRouter(ByVal myList As List(Of Processor))
m_KnownProcesses = myList
End Sub
The constructor for the processor object is like this:
Public Sub New(ByVal myNode As XmlNode)
Try
Config = myNode
m_QueueName = myNode.Attributes("queuename").Value
m_Type = myNode.Attributes("processtype").Value
StartListening()
Catch ex As Exception
RaiseEvent onProcessorError(ex)
End Try
End Sub
It also has a "start listening" subroutine associated which looks like this:
Private Sub StartListening()
Try
myProcQueue = New MessageQueue(m_QueueName, False, False, QueueAccessMode.SendAndReceive)
myProcQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(System.String)})
myProcQueue.UseJournalQueue = True
RaiseEvent onProcessorStarted("Processor listening to " & m_QueueName, "Started")
AddHandler myProcQueue.ReceiveCompleted, AddressOf MSMQ_ReceiveCompleted
myResult = myProcQueue.BeginReceive()
Catch ex As Exception
RaiseEvent onProcessorError(ex)
End Try
End Sub
Now when the router receives a message, it reads it from the queue like this:
Private Sub MSMQ_ReceiveCompleted(ByVal p_source As Object, ByVal p_objAsyncResult As ReceiveCompletedEventArgs)
Try
Dim myMessage As Message
myMessage = myReceiveQueue.EndReceive(p_objAsyncResult.AsyncResult)
RaiseEvent onRouterMessageReceived("Router", "New message Received in Router Queue" & Chr(13) & myMessage.ToString)
RouteMessage(myMessage)
myResult = myReceiveQueue.BeginReceive()
Catch ex As Exception
RaiseEvent onRouterError(ex)
End Try
End Sub
And it uses the RouteMessage function to send a call to the proper processor (right now there's just the one and until I can get it to accept messages there's no use to add any more). But here's the RouteMessage sub:
Private Sub RouteMessage(ByVal msgToProcess As Message)
Try
' get the XML from the body of the message
Dim xmlDoc As New Xml.XmlDocument
xmldoc.LoadXml(msgToProcess.Body)
Dim myNode As XmlNode
myNode = xmlDoc.SelectSingleNode("descendant::process")
' read the first child to determine what the next process is
Dim NextAction As String
NextAction = myNode.ChildNodes(0).Attributes("type").Value
For Each SingleProcess As Processor In m_KnownProcesses
If NextAction = SingleProcess.Config.Attributes("processtype").Value Then
'Dim myQueue As New MessageQueue(SingleProcess.myProcQueue.Path)
' myQueue.Send(myNode.OuterXml)
SingleProcess.myProcQueue.Send("Test Message")
'myQueue.Send("Test Message")
'myQueue = Nothing
'SingleProcess.myProcQueue.Send(myNode.OuterXml)
Exit For
End If
Next
Catch ex As Exception
RaiseEvent onRouterError(ex)
End Try
End Sub
As you can see in my for loop I've tried several different things. But nothing's working. I'm not even getting the processor to recognize the simple text message that I sent. No errors are being thrown that I can see... it's just not doing anything. I put a breakpoint on the processor's MSMQ_ReceiveCompleted subroutine and it never ever gets hit.
I saw an article somewhere in my research today that helped me find where the MSMQ queuing properties control panel is and it says that the message files folder, message logging folder and transaction logging folder is all the same one -- C:\Windows\System32\msmq\storage. I looked in there and opened what I found in notepad but can't read any of it.
How can I tell if the processor queue is even receiving the message at all? I'm so lost.
I hope someone can please help me understand what I'm doing wrong. I'd greatly, greatly appreciate it.Denise "Hypermommy" Duggan
|
|
|
|
|
I want to print crystal Report(10.5).
Default Printer:"Microsoft XPS Document Writer".
I want multiple pages to print.
If a report contain 10 pages then each page should be repeated as per requrement.
The code is in vb.net.
gReportDoc.PrintToPrinter(2, True, 0, 0)
The above statement should print double the copies in browser,but i get single copy of each page.
Also instead of direct printing,if i done preview.10 copies r get displayed.Its fine.
But there is printing tool above in crystal viwer.In that dialogbox if i give there: No of copies=2,then also unable to get multiple copies in browser.
is there any printer setting problem..?
But my vb vode is working fine,ie multple pages get printed in browser. In which I have set CR.CopiesToPrinter=2.
|
|
|
|