|
according to the code that I wrote above , I want to check the Value of "RegNo" (preventing duplicate the value of "RegNo" Field ), before Updating , but Always Execute this :
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
So my database never Update ...
....
Thanks
|
|
|
|
|
Is there is way to invoke solid edge using c#
Thanks
|
|
|
|
|
|
Thanks For reply
But not get proper answer
|
|
|
|
|
If you give a proper question, you'll get a proper answer. As I asked, what is Solid Edge? I could have assumed it was the CAD package, but that would have been an assumption which could have ended up wasting your time by supplying details of something that was completely inappropriate.
|
|
|
|
|
I Want to create Solid Edge drawing using C# application
Thanks
|
|
|
|
|
Again, WHAT IS SOLID EDGE??
When speaking with humans, the quality of the answer you get is directly dictated by the quality of the question you ask!
|
|
|
|
|
Thanks..
Solid edge is a software for making mechanical 3D drawings...I is just Like Autocad Software used for mechanical engineers drawings..
Thanks
|
|
|
|
|
The best place to ask your question would be the makers of SolidEdge, not a bunch of people who have never heard of it.
|
|
|
|
|
Not sure - but this set[^] of samples on Codeplex might help you.
|
|
|
|
|
|
My SQL command returns 3 rows which is verified in a SQL GUI. I run the same code and SqlDataReader returns only 2 of them. The same sql command returns 3 rows with SqlDataAdapter. Here is my code.
ds has 3 rows.
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VPO"].ConnectionString))
{
string sql="SELECT DISTINCT A.account_id, A.fname, A.lname,
FROM T_Test1 A WITH (NOLOCK) JOIN T_Test2 AF WITH (NOLOCK) ON A.Account_id=AF.Account_id
WHERE account_status = 'A' AND A.card IS NOT NULL
AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' AND AF.code = 'INE'";
SqlCommand command = new SqlCommand(sql.ToString(), connection);
command.CommandTimeout = 3600;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
}
|
|
|
|
|
I know that isn't an answer to your question but why are you executing this query twice?
NarVish wrote: using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
and
NarVish wrote: DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Just to show the difference, I added the SqlDataAdapter code. It will be removed.
|
|
|
|
|
what happens if the you run the query direct on your database?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
If I run the query on database (SQL GUI), it is showing three records
|
|
|
|
|
What are the three rows, and which one is not being returned?
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
DataReader didn't read first record.
|
|
|
|
|
Hm. Unlikely - but suspicious.
I use code very similar to yours every day - and it has never missed out a row (particularly not the first row). I notice that the code you show a fragment of isn't the code you are actually using - can you post that bit? It seems unlikely that a "missing the first row" problem would be that specific is it was an SQlReader bug. Oh, and can you show the three rows worth of data and I'll try it here, see what happens.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
NarVish wrote: I run the same code and SqlDataReader returns only 2 of them. The DataAdapter does not remove records from the resultset that it receives.
NarVish wrote: AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' Are you sure those dates are correctly interpreted?
Use a parameterized query to prevent questions like those
Further, "sql" is already a string (no need to call .ToString) and SqlCommand is a disposable.
NarVish wrote: My SQL command returns 3 rows which is verified in a SQL GUI. Also do verify that you're pointing to the same database in both environments.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Also do verify that you're pointing to the same database in both environments
Good thing to point out! I've been bitten by that one before.
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
I'm suspicious that you're missing the code inside reader.Read(). I have the feeling that the problem you are looking at lies in that block. As a test, replace your reader.Read line with this
int count = 0;
while (reader.Read())
{
Debug.WriteLine("Count is {0}", ++count); Then, when you are debugging your app, take a look at what appears in the output window in Visual Studio.
|
|
|
|
|
One of the line in using section is reading the first record. In while loop, it is reading from second record. I removed the below if condition and it worked fine. Thank you all for your replies. Sorry for not posting that line, as I thought that line is handling only exception.
if (!reader.Read())
throw new ApplicationException("MISSING Transaction Returned By Financial Institution. Transaction was not found in the database.");
while (reader.Read())
{}
|
|
|
|
|
At least the mystery has been solved. The effect you were after here could have been achieved by using the following instead:
if (!reader.HasRows)
{
throw new ApplicationException("MISSING Transaction Returned By Financial Institution. Transaction was not found in the database.");
}
while (reader.Read())
{
} For future reference, the act of calling Read automatically moves the record to the next available record (if one's present) when it completes. It implements a firehose cursor, whereby data is effectively squirted at you.
|
|
|
|
|
Hi,
New to coding. Trying to teach myself. I am wanting to test an input against a name and if it is true then proceed. If it is not true display something different. Here is what I wrote along with the error. Obviously it's wrong. Any help would be appreciated. Thanks
Console.WriteLine(name + " What is her name?");
String herName = Console.ReadLine();
if (herName == ashley)
{
do this stuff...
}
Error 1 The name 'ashley' does not exist in the current context
modified 1-Sep-13 23:52pm.
|
|
|
|