|
Hi
I am using C# and Visual Studio 2005 to develop a Windows Application. I use the designer to bind a DataGridView to a table in a MS Access database.
When I use the designer the following code is automatically generated in the Form_Load method:
this.procPatientList_AllInfoTableAdapter.Fill(this.patientStatusDataSet.procPatientList_AllInfo);
I try to update the database when changes have been made to the data in the DataGridView, but cannot find what to use or how to do it. In the past I used to write my own code and could do updates. I am trying now to learn about the built-in functionality, but I am struggling.
Neither procPatientList_AllInfoTableAdapter nor patientStatusDataSet has any Update methods.
Any assistance will be appreciated.
Thanks.
Kobus
|
|
|
|
|
See this[^] or you can search in google with keyword CommandBuilder
|
|
|
|
|
Dave Kreskowiak(CodeProject) tought me to Stop using wizards when am doing my Daatabase work.
wizards have limitation and its not easy to debug if you did not write the code for yourself. i suggest you start writting your data layer so that you can see what is the Problem. as you said you use to write the code your self, why did you stop because its the best way of doing things, i have an Article that can get you started on how to update a Datagrid.
http://www.codeproject.com/KB/cs/N-Tier22.aspx[^]
Hope i Helped
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/SQL7/2000/2005/2008
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@its.co.za
|
|
|
|
|
hello sir
i want a c# code for merge two individual picture in to asingle picturebox. Then the images are merge in one is back image and next one is fore image to differetiate these two images
please help me
ok bye
|
|
|
|
|
jaraldumary wrote: i want a c# code
I want candy.
|
|
|
|
|
You have to create a third Image painting both of your source images into this new image, then you can set the PictureBox to this third image.
No, I can't write the code for you. I simply don't have the time right now.
|
|
|
|
|
Hi all,
I want to change the paper settings to customized one based on the culture info, I mean for now it is coming as A4 by default. For eg, if they try to do print using some other culture info, it should change to letter formate, how to set like that.
Please suggest me
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
hello sir
i want a sample code for the above things (merge two images)
|
|
|
|
|
Been a while since I worked with this but from what I remember you can pas a printersettings and a pagesettings object with the report.open method.
See if that helps you.
|
|
|
|
|
Thankyou very much for your suggestion. But please explain me with a sample.
THank you again
Know is Drop, Unknown is Ocean
|
|
|
|
|
As I said in my original reply it's been a while so I don't know the exact code.
But normally you should have an instance of your report
and that instance should have a open method in which you can pass the objects pagesettings and printersettings
pagesettings[^]
printersettings[^]
|
|
|
|
|
Dear all,
I'm trying to get my computer to listen on a port and pass on the received data ( after some modification ) over Multicast. I'm receiving data on the socket every second. I wrote the code below and it works perfect.
The problem that I require some assistance with is pretty simply. Everytime a string of data is received, the socket is closed and new socket is opened to wait for the next string. When the next string of data comes in, it gets processed and the socket is closed again. This means that after a period of time, lots of socket connections are made. One of them is active and the others are in a TIME_WAIT state ( and that list keeps growing ) Is there a way around this ?
Int32 port = 31008;
IPAddress localAddr = IPAddress.Any;
server = new TcpListener(localAddr, port);
server.Start();
Byte[] bytes = new Byte[256];
String data = null;
while (true)
{
client = server.AcceptTcpClient();
data = null;
NetworkStream stream = client.GetStream();
int i;
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
data = data.ToUpper();
byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
SendMulticast(MultiCastIP, MultiCastPort, msg);
}
client.Close();
}
kind regards,
Rick
|
|
|
|
|
The TIME_WAIT state for a period of time is normal/default socket behavior.
If you're absolutely sure all data is sent, then you may be able to set the
LingerState to on/0sec:
LingerOption lingerOption = new LingerOption (true, 0);
client.LingerState = lingerOption;
You also should call Close() on your NetworkStream
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
My question is that.. Report.rdlc is class ? how to i format the report at runtime such as i want change the fontstyle before print the report while runing the program.
thanks.
|
|
|
|
|
Hi,
as the title indicates I want to mark a field in a child class with a NonSerialized attribute so that it won't be serialized. Simply put:
[Serializable]
class Parent
{
protected int SomeField;
}
[Serializable]
class Child : Parent
{
[NonSerialized]
protected int SomeField;
}
Of course this does not work, but also the new keyword does not help me because it only hides the field and does not overwrite it. Is there any other way to achieve the desired effect?
Regards
Dust Signs
The number you dialed is imaginary. Please turn your phone by 90 degrees and try again
|
|
|
|
|
I thought NonSerialized is intended for this purpose, or what whould you expect?
|
|
|
|
|
Hi,
of course you are right, but I need this as the parent class saves information in this field which the child classes do not need anymore because they compute it dynamically. And of course we are not talking about an int field, but about an array of a more complex data type which would consume up to 20 or 30 KB per instance which would be serialized and "thrown away" after deserialization as it has to be recomputed anyways. I hope this helps to better understand the purpose of what I want to achieve.
Dust Signs
The number you dialed is imaginary. Please turn your phone by 90 degrees and try again
|
|
|
|
|
If you don't want to store it, but on deserialization want to get default values. Then maybe the OnDeserializedAttribute can be of use...
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.ondeserializedattribute.aspx
|
|
|
|
|
Thanks for the link, this seems quite useful. But this does not solve my problem: the parent class has to save the field whereas the child classes don't have to save it, so how do I declare the field in the child classes? As I said I cannot mark it as NonSerialized in the parent class as it needs to be saved there.
Dust Signs
The number you dialed is imaginary. Please turn your phone by 90 degrees and try again
|
|
|
|
|
maybe something like this could be usefull?!
[OnDeserializing()]
internal void OnDeserializingMethod(StreamingContext context)
{
this.nonserializedmember = reInitialise();
foreach (Child c in this.childs) {
child.newNonserializedValue = this.nonserializedmember;
}
}
|
|
|
|
|
I just answered this question myself . I just had to use OnSerializing and OnSerialized to set the field to null and reset it to its old value respectively. Thank you very much for your help.
Regards,
Dust Signs
The number you dialed is imaginary. Please turn your phone by 90 degrees and try again
|
|
|
|
|
No prob
|
|
|
|
|
I just don't get it why is it so complex to make a simple update...
I want trough a procedure to modify all the rows in a table like so: suppose I have a table with colums a, b, and c. c is identified by a and b. The procedure has the parameters a,b and c.
a,b,c
Example: UpdateazaCantCont(1,3,5) must add 5 to the old value of c. So if one row in the database table values are 1,3,8 the new values must be 1,3,13.
Please help me, because I'm in an death stop in my project!
The procedure i've wrote gives me no error, but it doesnt do anything.
Here's the code I have written:
private void UpdateazaCantCont(string aVal, string bVal, int cVal)
{
DataSet mds = new DataSet();
OleDbDataAdapter mda = new OleDbDataAdapter("select * from table where a='" + aVal + "'and b='" + bVal + "'", sirConex);
mda.Fill(mds,"continut_locatie");
DataTable t = mds.Tables[0];
DataRow[] r = t.Select("a='"+aVal+"b='"+ bVal + "'");
for (int i=0; i<r.length;>
string sirUpdate = "Update table set c=c+'"+cVal+"'where a='" + aVal + " and b='" + bVal + "'";
OleDbConnection myConex = new OleDbConnection(sirConex);
OleDbCommand cmd = new OleDbCommand(sirUpdate, myConex);
cmd.CommandText = sirUpdate;
mda.UpdateCommand = cmd;
try
{
mda.Update(mds, "table");
}
catch (Exception ex)
{
MessageBox.Show("Eroare: " + ex);
}
}
|
|
|
|
|
First of all, because aVal and bVal are strings, it's possible I can erase your database. Do you know about SQL Injection ?
Second, why use a dataset to get back a single value ?
Third, NEVER assume that an array has any values in it, without checking.
Fourth, what's the point of doing a select when you already have only those values in the table ?
you seem to be some of the way along, although you could do all of this in a stored proc and with 3 lines of code on the C# side.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks for your reply. Can you tell me those 3 lines?
|
|
|
|