|
Hi everyone
I am trying to use the Form property TranseparencyKey on a form which is a child for a MidParent from . The result should make the selected color area transparent and so the image of the MidParent form apears .
this feature doe not work , it works only if the form is not owned by a MidParent . any Ideas ?
Thanx .
|
|
|
|
|
Forms do weird things when you make them transparent from my experiences.
|
|
|
|
|
hi guys! I am building an app, and at one point I want to insert data in local DB, everything goes ok, connString is opening, but the data is not going in to the DB, am I missing something in the code?
string query = "INSERT INTO Orders(Order_Name, Order_Data, DateInserted, OrderStatus) VALUES ('"+ Name + "','" + Data + "','" + DateTime.Now + "','" + City + "')";
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\OStorage.mdf;Integrated Security=True;User Instance=True;Trusted_Connection=Yes");
conn.Open();
SqlCommand comm = new SqlCommand(query, conn);
comm.ExecuteNonQuery();
I am executing the same query with SSMSE, and it is working without any problem, so I really don't know where I am making a mistake. Thanks ahead for any help
|
|
|
|
|
How many rows affected does ExecuteNonQuery() return? Do you use a SqlTransaction[^] to Commit the changes to the database?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It is affecting one row each time the query is executed
|
|
|
|
|
So do you commit the insert using the SqlTransaction.Commit method?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
no, how should I do that? I haven't used that method at all for now, can you pls give me some help how should i use it? Thx
|
|
|
|
|
|
thx, I will check it out now...
|
|
|
|
|
I use it the informations what you provide me, and it gives me error after the ExecuteNonQuery line, here is how I tried to solve:
SqlTransaction transaction;
transaction = conn.BeginTransaction("BeginTransaction");
SqlCommand command = conn.CreateCommand();
try
{
command.CommandText = query;
command.ExecuteNonQuery();
transaction.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.ToString(), ex);
}
finally
{
conn.Close();
}
This is the exception:
System.InvalidOperationException: ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
|
|
|
|
|
You forgot to insert command.Transaction = transaction before executing the query.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
So do you get an error?
Are you attaching the correct database file when you look for the data?
|
|
|
|
|
I do not get any error, I am going through each line of the code, everything seems OK, the right DB is attached and at the end I do not get anything in the DB, is the ExecuteNonQuery method declared ok?
|
|
|
|
|
By the way, your code is also vulnerable to SQL injections[^], you should fix that
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You are facing a common problem here I suspect, where the database is being copied over with a default instance. Basically, what is happening is that you have a default version of the database which is being copied over every time you run the application.
|
|
|
|
|
Any help with that, how I can solve?? Thx
|
|
|
|
|
The article does describe how to solve it. Look in the section "Parameterised Queries" in the article
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have 2 windows forms, lets say Form1 and Form2........after designing I came to knowe that Form2 should execute before Form1...........how can I do that........
|
|
|
|
|
Depends on how the first form is created and displayed. Usually, if you create a simple Windows Forms application, then in your source file Program.cs you will find something like this:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
There you can simply change new Form1() to new Form2() (or their correct form type name).
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hey just change in Program.Cs
<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
Application.Run(new Form2());
}<br />
|
|
|
|
|
Hi,
I am using filesystemwatcher to mononitor a folder when changes occur to files in that folder.
I am happy with the changes it detects and it seems it is working correctly.
Question:
How is it possible to display the notifyfilter which gets detected i.e. size or filename, LastWrite, etc...
Thanks
|
|
|
|
|
|
Hi,
Thanks for the link.
Un-fortunately I do not see anything relatinig to my issue.
I am basically tring to detect what has exactly changed.
For example, I detect e.ChangeType where e is FileSystemEventArgs
But do not detect whether it is a size or creationtime or lastaccess or what change it exactly is.
Thanks
|
|
|
|
|
i think if you check The tool and code throughly you will get your answer.
|
|
|
|