|
Can we get some sample code so we can try to help?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
sakis24 wrote: the code is correct..
Obviously its not.
From the very poor information you have supplied its impossible to say what is wrong. Do you get any errors when you save your data, do you reload it when your application starts? There are just so many things that could be wrong.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
here is the comands
private void InitializeCommands()
{
//INSERT
dataAdapter.InsertCommand = conn.CreateCommand();
dataAdapter.InsertCommand.CommandText =
"SET IDENTITY_INSERT Producer ON insert into Producer(Pid,AFM,LastName,FirstName,City,ZipCode,Adress) values(@Pid,@AFM,@LastName,@FirstName,@City,@ZipCode,@Adress)";
AddParams(dataAdapter.InsertCommand, "Pid", "AFM", "LastName", "FirstName", "City", "ZipCode", "Adress");
//UPDATE
dataAdapter.UpdateCommand = conn.CreateCommand();
dataAdapter.UpdateCommand.CommandText =
"update Producer set AFM=@AFM, LastName=@LastName, FirstName=@FirstName, City=@City, ZipCode=@ZipCode, Adress=@Adress where Pid=@Pid ";
AddParams(dataAdapter.UpdateCommand, "Pid", "AFM", "LastName", "FirstName", "City", "ZipCode", "Adress");
//DELETE
dataAdapter.DeleteCommand = conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText =
"delete from Producer where Pid = @Pid";
AddParams(dataAdapter.DeleteCommand, "Pid");
}
the add paremateres method
private void AddParams(SqlCommand cmd, params string[] cols)
{
foreach (string col in cols)
{
cmd.Parameters.Add("@" + col, SqlDbType.NVarChar, 0, col);
}
}
the insert button
private void btnAdd_Click(object sender, EventArgs e)
{
insertRec = true;
DataRow row = dt.NewRow();
dt.Rows.Add(row);
//MessageBox.Show(totalRec.ToString());
totalRec = dt.Rows.Count;
curRec = totalRec-1;
row["Pid"] = totalRec;
txtpid.Text = totalRec.ToString();
txtAFM.Text = "";
txtln.Text = "";
txtfn.Text = "";
txtCity.Text = "";
txtZip.Text = "";
txtAdr.Text = "";
btnSave.Enabled = true;
}
and the save button
private void btnSave_Click_1(object sender, EventArgs e)
{
DataRow row = dt.Rows[curRec];
//MessageBox.Show(totalRec.ToString());
//MessageBox.Show(curRec.ToString());
row.BeginEdit();
row["Pid"] = txtpid.Text;
row["AFM"] = txtAFM.Text;
row["LastName"] = txtln.Text;
row["FirstName"] = txtfn.Text;
row["City"] = txtCity.Text;
row["ZipCode"] = txtZip.Text;
row["Adress"] = txtAdr.Text;
row.EndEdit();
dataAdapter.Update(ds, "buffer");
ds.AcceptChanges();
CreateDir();
ToggleControls(true);
insertRec = !true;
}
i havevreated the dataset,dataadapter, the conection string and the datatable of course
|
|
|
|
|
hi
i want to have a password on my database
i tried "databasepassword" but it does not work
i think it just work in "sql mobile edition"
do you have an idea ?
please help me !!!!
|
|
|
|
|
Which database are you using?
|
|
|
|
|
OK - I've 5ed this to counter the 1 you received for not being able to read this morons mind.
|
|
|
|
|
Ah, not worth worrying about Pete. Somebody voted him down, and he assumed it was me etc. etc. etc. It's a whole viscous circle.
By the way, did you ever have a look at that Visual WebGUI thing I mentioned, er..., several months and a different lifetime ago? Looked pretty nifty to me.
|
|
|
|
|
I have a string that looks kinda like this..
Name:Name1/Name2.Name3.Name4
If i try to save using this as the file name it calls it invalid so I need a way to parse through it and replace the illegal characters with ... say.. an underscore _
Can someone help me with this?
tia
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Assuming the variable name holding the string is 'aString',
aString = aString.Replace(@"/", "_");
will do it character by character.
I think there's also a way to replace any of a group of characters, but if so, I can't remember what it is.
|
|
|
|
|
Thanks for this info. Just the kind of thing I needed.
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
|
Martin, you beat me to recommending regex and Expresso. I'll second your suggestion
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for the info I have been trying to take all this in..
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
I need to intercept text being entered into a text box, and remove a space if it is typed. The problem with the following code is that the cursor ends up at the beginning of the string, not the end. Say the user types 'a' and then a space, i want the text box to show 'a' with the cursor after the 'a', not before the 'a'. Is there a way to specify the cursor location?
textBoxA_TextChanged (object sender, System.EventArgs.e)
{
if (textBoxA.Text.Contains(" "))
{
textBoxA.Text = textBoxA.Text.Trim();
}
}
Also, is there a way to supress the TextChanged event happening a second time, since I'm changing the text within the event handler? With a data grid, for example you can do the BeginInit/EndInit. The text box doesn't support ISupportInitialize, correct? Other things trigger off each character that is typed so I need to check character by character.
|
|
|
|
|
something like this?
bool ignoreTextChanges = false;
void textBoxA_TextChanged (object sender, System.EventArgs.e)
{
if (ignoreTextChanges)
{
return;
}
if (textBoxA.Text.Contains(" "))
{
ignoreTextChanges = true;
textBoxA.Text = textBoxA.Text.Trim();
textBoxA.SelectionStart = textBoxA.Text.Length;
ignoreTextChanges = false;
}
}
it may not be the prettiest but it should work
|
|
|
|
|
Works brilliantly! Thanks.
|
|
|
|
|
OleDbConnection mySqlConn = new OleDbConnection(SqlConnString);
OleDbCommand mySqlCom = mySqlConn.CreateCommand();
OleDbConnection mySqlConn2 = new OleDbConnection(Sql2ConnString);
OleDbCommand mySqlCom2 = mySqlConn2.CreateCommand();
mySqlCom.CommandText = "SELECT * FROM OISInt_Contact";
OleDbDataAdapter mySqlAd = new OleDbDataAdapter();
mySqlAd.SelectCommand = mySqlCom;
DataSet myDS = new DataSet();
mySqlConn.Open();
mySqlAd.Fill(myDS, "OISInt_Contact");
mySqlCom2.CommandText = "SELECT * FROM OISInt_Contact";
OleDbDataAdapter mySqlAd2 = new OleDbDataAdapter();
mySqlAd2.SelectCommand = mySqlCom2;
DataSet myDS2 = new DataSet();
mySqlConn2.Open();
mySqlAd2.Fill(myDS2, "OISInt_Contact");
mySqlConn.Close();
mySqlConn2.Close();
myDS2.Merge(myDS, true, MissingSchemaAction.AddWithKey);
foreach (DataTable dt in myDS2.Tables)
{
foreach (DataRow dr in dt.Rows)
{
foreach (DataColumn dc in dt.Columns)
{
}
}
}
mySqlAd2.SelectCommand.Connection = mySqlConn2;
mySqlAd2.InsertCommand = new OleDbCommand(String.Format("OISInt_ContactInsert", myDS.Tables));
mySqlAd2.InsertCommand.CommandType = CommandType.StoredProcedure;
mySqlAd2.Update(myDS2, "OISInt_Contact");
when I do a step into all data is in the data set and it merges but goes not commit or accept changes to the database I trying to move it to.
Learning to Code
|
|
|
|
|
My application working fine in the dev environment.But in the testing /production environment
it is not working because that environment has only
windows server 2003
IIS
.net2.0 framework
In my application I have Used some microsoft VC++ dll's also along with .net dll's.
Now Iam getting "RUNTime Error" pop-up screen message as below
" The Application has been terminated in an Unusual Way"
On googling i came to know that some dll's like msvcrt.dll of windows server 2003 has to be changed...But Iam not pretty sure about it..
In Production/test environment there is only framework installed ,but there is no visual studio installed on it.may be due that this error may occur...
So kindly post your suggestions and views to help me
I tried the following as suggested by you:
1. I have installled the redistributable package suggested by you.
after installing i restarted the PC even now also I got the same runtime pop-up error.
2. Then I checked even with the dependency walker for the dll.
I found that there is no miising dll.
3. Then I tried by installing Visual C++ express edition..even then also i got the same pop-up error.
Kindly help me.....
|
|
|
|
|
Might need to have some of those dll's your talking about to be registered with regsrv.exe. But I guess that depends on the dll's your using and your deployment method.
Just because we can; does not mean we should.
|
|
|
|
|
I have a process that causes Virtual Bytes counter to constantly increase (to the point that the program throws an OutOfMemory exception after a few hours of running), but Private Bytes are not increasing. Is there anything we can do to trigger virtual memory collection? GC.Collect is obviously not helping.
|
|
|
|
|
Managed memory doesn't get fragmented, as the garbage collector compacts the heap. If your application really leaks memory, it's unmanaged memory. Are you disposing all objects that needs disposing?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa,
I use an external C++ library (QuickFix), so I would imagine that's where unmanaged memory is used. Otherwise, everything in my code is managed C#. I thought maybe in some momemnt of lunacy I did write unmanaged code, but search for words "unsafe" or "~" or "!" produces nothing.
When you say "application really leaks memory", wouldn't it cause increase in the Private Bytes memory? I don't observe that. The Private Bytes are increasing throughout the day, but every couple of hours they drastically go down. This is really purzzling, as I am watching GC Gen 0, GC Gen 1, and GC Gen 2 counters, and they all increment so I would think that Private Bytes would be managed better. So the infrequent drastic drop in Private Bytes is puzzling. Virtual Bytes, on the other hand, never go down.
I am trying memory comparisions between WindDbg breakpoints, but that isn't going all that quickly
|
|
|
|
|
Does your app do any kind of memory mapping? That would contribute to the Virtual bytes counter as well.
|
|
|
|
|
Senthil,
no, no memory mappings. Since I don't know how StreamWriter uses memory, one thing that I'd think can potentially cause problems is me writing large (GBs) log files.
It must be the unmanaged memory from the external unmanaged C++ library. I'm out of ideas as to what else can it be. The CLR profiler is showing no glaring problems with .Net-managed memory.
|
|
|
|
|
I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();
}
Am I close??
|
|
|
|