|
itbrainsoft wrote:
It is User.hbm.xml :
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate.Examples.QuickStart
{
public class User
{
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;
public User()
{
}
public string Id
{
get { return id; }
set { id = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string EmailAddress
{
get { return emailAddress; }
set { emailAddress = value; }
}
public DateTime LastLogon
{
get { return lastLogon; }
set { lastLogon = value; }
}
}
Last time I looked, that's not a hbm.xml file.(hibernate mapping xml file).
You have to create a valid mapping file in xml for hibernate that tells hibernate which table this class is bound to, and to map up the different properties to columns.
-Larantz
|
|
|
|
|
Hi,
I have a problem how to bind our database data into a listview..is it the same way we bind the data into gridview?could someone give me an example?
Thank You
|
|
|
|
|
What problem?
Explain clearly you problem? so that only we can help you.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
I'm sorry maybe my english is bad
for example:
I have a table name Contact in my database..and i want the data on that table to be show on a Listview..I already know how to bind it on a gridview, but i can't find a way to bind the data on a ListView..i use SQLServer 2005 Express Edition for the database
Thank You
|
|
|
|
|
Hi,
In ListView you will have to Enumerate the datasource and fill it. For example, if your datasource is a DataTable, you can write the following:
foreach(DataRow row in table.Rows)
{
ListViewItem item = new ListViewItem();
item.Text = row["Description"].ToString();
item.Tag = row["ID"].ToString();
//For other coulmns
items.SubItems.Add(row["OtherColumn"].ToString();
}
Hope this helps.
|
|
|
|
|
Hi Guys and Gals.
Well, I dont know if I am posting this at the right place. Hope I did so that I dont irritate anyone. My question is as follows. We have 2 databases. SQL (online) and Access (offline). I need to implement code in a windows application that will (on a click of a button) synchronize these two databases so that they are always xactly the same.
Does anyone out there know how to do this or at least where I can find code that will guide me please?
Help is greatly appreciated since this is rather urgent.
Regards,
Elizma
|
|
|
|
|
Off the top of my head, here is a rough idea of how to do it:
First thing to do is to make sure you have the same table schema in the databases, and secondly you'll want to load everything from the SQL (online) databases into a dataset, then lastly, dump the dataset into Access.
One thing I would do with the Access database, is to keep a timestamp field of the data records that get synch'ed in from SQL.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
My databases are already exactly the same with the same schemas the works. The problem is that users will work on the Access db when they are out of the office. When they return they need to upload the newly inserted information from Access to SQL. Then since there could be changes in the SQL DB, we need replicate the changes to Access.
|
|
|
|
|
Okay, like I mentioned at the end of my last post, have a timestamp and that can help you with the synch.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I am trying to find a quick way to add 1 dimensional array into multidimensional array. For example:
<br />
object[] oneDArray1 = new object[10];<br />
object[] oneDArray2 = new object[10];<br />
object[] oneDArray3 = new object[10];<br />
Then, I need to add this array into 2D Multidimensional array.
<br />
object[,] twoDArray = new object[3, 10];<br />
The reason I need to do this is because I have a DataSet and I need to convert this DataSet to Excel Application.
Currently, I do the following:
<br />
oRng.Value2 = oDataTable.Rows[iRowIdx].ItemArray<br />
This code work if the Range is within single row. Now, if I have 1000 rows, this is process is very slow. It takes about 20 seconds to loop through the range and set the rows.
Alternatively, I could set the value of the range at one go. For example I want to set the value from Row #1 Column #1 to Row #1000 Column #1000, I must do
<br />
object[,] 2DMultiDimensionalArray = new object[1000, 1000];<br />
oRng = oSheet.get_Range("A1", "ALL1000");<br />
oRng.Value2 = 2DMultiDimensionalArray;<br />
In order to set the excel value at one go, I MUST convert each DataRow.ItemArray into MultiDimensional array. I need to add Single Dimensional Array into MultiDimensional array (NOT jagged array because I have try it and it throw an error).
An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in mscorlib.dll
Additional information: Specified array was not of the expected type.
Any help is greatly appreciated!
Thanks
|
|
|
|
|
Do you want to export a DataTable to Excel? I am asking, because I would then suggest to use instead of arrays two loops. An outer-loop to do your rows and a inner-loop to do your columns.
Much faster than arrays.
Regards,
Elizma
|
|
|
|
|
Hi Elizma,
Yes, I am indeed exporting DataTable to Excel.
Doing loop for each row and each column will be quick if the number of columns aren't big. Here, I am talking about about 1000+ rows by 1000+ columns.
Currently, if I do
for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
{
oRng = oSht.get_Range("A" + iRow.ToString(), strLastCol + iRow.ToString());
oRng.Value2 = (System.Array)dt.Rows[iRow].ItemArray;
}
This code is about 30x faster than nested loop. In my PC this loop takes about 20 seconds where as nested loop (to set each cell) takes about 10 minutes.
However, if you set directly to MultiDimensional Array, it takes less than 1 second (and probably few seconds to add the 1D array into Multidimensional array).
I am starting to think that it is impossible to add 1D array to Multidimensional array without nested loop
Any other idea to speed up this process? Thanks for any input/help.
Cheers
|
|
|
|
|
Hope this[^] article will give an idea about the arrays.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Hi Satips,
Thanks for the link. But it doesn't answer my question
|
|
|
|
|
Satips do you intentionally just answer questions badly?
|
|
|
|
|
Hi,
I embedded windows media player 11 on a form, and I add a few files to the currentplaylist of it. like:
WMPLib.IWMPMedia m= wmp.mediaCollection.add(sFile);
wmp.currentPlaylist.appendItem(m);
I want this playlist "Repeat" forever. but the function "repeat/Ctlcontrols.repeat" is gone. How to do this????
I don't want to create my own timeline thread to check the duration by the way.
Also I could not use the StatusChange and PlayStateChange event, it is not recommended by MS.
thanks a lot in advance!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
hello all;
i am working with an external electronic curcuit and i want to take the data that this circuit provides by serial port to the computer and by windows application open the port and read the data and finally to draw these data.
please any body hase an idea about how can i do what i am talking about using c# 2005 please help me.
Thank you all
ahmad al-omar
ahmad al-omar
|
|
|
|
|
It is very simple to open/read from a port in .NET.
Investigate (aka MSDN/Google) the System.IO.Ports namespace and in particular the System.IO.Ports.SerialPort class.
A small sample:
System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort("COM1"); //whatever com-port your device is hooked to
port.Open();
string oneLine = port.ReadLine();
Hope this gets you started.
-Phil
|
|
|
|
|
thank you
i made a button to open the port and other to read the data but when i click on the read button my PC stop working and i have to reset it
may be i wrote a wrong code and may be i choose wrong COM port
i will try it again
thank you
ahmad al-omar
|
|
|
|
|
[shameful plug]Take a look at my article on Terminal3[^], this has a simple graphing feature built into it as a demonstration. If you have any queries don't hesitate to ask.[/shameful plug]
|
|
|
|
|
thank you
but i dont know how to use your program when i choose terminal or graph no thing appears to me i dont know how to use it , can you help me in order to understand the operation.
thank you
ahmad al-omar
|
|
|
|
|
The code which displays stuff on the graph is in GraphWindow.cs. I intended this program as more of a reference than to actually use it. To see stuff in action do the following:
- File | New | Graph
- Click the SerialPort icon on the toolbar, this will add a port to the graph window (multiple ones are supported).
- Click the little drop-down arrow of the new button and select Properties.
- Edit the port settings to what you require (note you must change the Color as this defaults to White and will not display on the graph).
- Click the little drop-down arrow and select open, this will open the port and is ready to receive data.
To see data being plotted the sample program requires that data being read on the serial port has two double values seperated by a comma, it then splits these and uses them as the X and Y values of the graph. Note this was an example so there is no complex error checking or anything like that. One problem you might come across is the two values and the comma must be read in all at the same time. How I used this as a demo for my colleagues was to set up the com0com virtual serial port drivers and then I could have another window open in the terminal window and use the combo box to send the comma-seperated values as one string.
Hope that helps, by the way, if you're doing work with serial ports I strongly recommend installing these virtual ports, it makes it perfect for testing stuff because you don't need two hardware ports and a null modem cable, what you write to one port (COM10 on mine) is sent out on the other (COM11 on mine) and vice versa so you can get applications to talk to each other and you can debug things in Hyperterminal etc without having to hook up the hardware system.
|
|
|
|
|
I have an odd problem with remoting. I have an application that acts as a server for my remote object and also acts as a client for the same object (so it can work on it and react to changes to it). So in this case the object is in not just on the same machine, but even in the same process. Now this works fine most of the time, but on some machines, when the computer is connected to the internet it works, but when it's disconnected it doesn't work. I get an error "No connection could be made because the target machine actively refused it".
I added a sleep statement between the publishing of the object and the attempt by the server to connect to it and I could see using netstat.exe that the object is published and listening. Does anybody have any ideas as to what might be happening here?
Of course, it works just fine on my development box
|
|
|
|
|
Sounds like a dns problem of some sort.
Did you define the connectionstring to the hosting process as localhost or someother hostname? If the hostname cannot be resolved due to lost connection to your dns server, you might get the results you're seeing.
-Larantz
|
|
|
|
|
Thanks for the reply.
I should be connecting to the localhost. Here's how I have it set up:
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();<br />
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;<br />
IDictionary props = new Hashtable();<br />
props["port"] = mySettings.TCPPort; <br />
TcpChannel channel = new TcpChannel(props, null, provider);<br />
ChannelServices.RegisterChannel(channel, false);<br />
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyMessenger), "MyRemoteService", WellKnownObjectMode.Singleton);<br />
<br />
messenger = (MyMessenger)Activator.GetObject(typeof(MyMessenger), "tcp://localhost:" + mySettings.TCPPort + "/MyRemoteService");
Am I doing this correctly?
|
|
|
|