Click here to Skip to main content
13,054,018 members (66,153 online)

Comments by Wendelius (Top 200 by date)

Wendelius 10-Jul-17 11:42am View
What should happen if the sentence contains two or more of the words?
Wendelius 8-Jul-17 5:46am View
Not sure why you got downvoted, countered.
Wendelius 8-Jul-17 5:43am View
What have you done so far and where are you stuck at?
Wendelius 7-Jul-17 8:51am View
Glad it helped :)
Wendelius 6-Jul-17 13:24pm View
See the updated answer
Wendelius 19-Jun-17 7:17am View
Okay, so the problem is that you want to continue even if an error pccurs.

As Andy Lang already pointed out you can utilize error handling. Have a look at TRY...CATCH (Transact-SQL) | Microsoft Docs[^] and RAISERROR (Transact-SQL) | Microsoft Docs[^]
Wendelius 17-Jun-17 15:47pm View
With auto numbered field you cannot achieve a situation where there wouldn't be a hole in the numbering.

What about deletes, what are you going to do if a record is deleted. Suppose you have rows 1, 2, 3, and 4. Then number 2 is deleted, what happens?

As I explained, by definition a surrogate key is just a unique number, nothing else. If the numbering needs to be continuous, it sounds like you're trying to build something else than a key.
Wendelius 16-Jun-17 17:57pm View
Glad if it helped!
Wendelius 16-Jun-17 8:57am View
As said, use the debugger to make sure this is the problem.

To resolve this, change code to something like

if (item.Cells[1].Value != null && bool.Parse(item.Cells[1].Value.ToString()))

But also note that as said in the beginning, you really should use paremeters
Wendelius 16-Jun-17 8:39am View
Now using debugger, check:
- Does the item contain the specified cell. In other words, is item.Cells[1] null? In this case Value will fail
- If it's not null then does it have a value or is Value null. In this case ToString will fail
Wendelius 16-Jun-17 8:04am View
On which line?
Wendelius 16-Jun-17 0:25am View
What was the error you got with them?
Wendelius 2-Jun-17 13:24pm View
About indexing. Primary and unique keys are indexed automatically. What you need to do is to create sufficient indexes on other columns to support operations. For example in your example, the Bill_Id should be indexed in BillContent table because you're going to use it excessively in select statements.

Then about surrogates, it's a key that has no other purpose than to be just a key. One example is autonumbered field as you have used in your example. You cand find more information in Surrogate key - Wikipedia[^]
Wendelius 24-May-17 7:18am View
I see you copied my solution to your question. I take it there were some issues with it, so can you explain what problems you faced?
Wendelius 17-Apr-17 4:29am View
Based on the description from Solution 2:
"ex:-I have 2,3,4,6,7,8 sno(index number) records(1,5 I already delete) but this displaying numbers 1,2,3,4,5,6. That is what i want. But When I try to delete 2 record it is not.because no 2 is existing in both. but i tried to delete 5th record it will delete. because that 5th sno(index number) record index is not in database file but is there in this list what you told, so it will delete and numbers also updated from begining. Maybe be I am thinking I explained as much as I can."

I'm not sure if I understand correctly, but are you trying to delete/update the record based on the ordinals? For example if you have values 1,5,9, and 11 in the database you would have 4 records. When ordered you would have list 1,2,3, and 4. However, you cannot update record 2 based on the ordinal since the key value is 5. So in order to manipulate the record, always use the key value, not the position in a list or similar.

On the other hand it may be that I misunderstood your example...
Wendelius 16-Apr-17 10:16am View
If that's the case then remove the semicolon ending the first query. Also the ORDER BY must be only once and in the end. In the order by you cannot refer to columns by their names, instead you need to use ordinal numbers based on the location in your query.

For example

SELECT name , department
FROM employee
SELECT name, department
FROM contractor

The query above selects the data from both tables and sorts the result first based on department then based on name.
Wendelius 16-Apr-17 7:34am View
As said, you can't get a continuous sequence of numbers with identity field. The sole purpose of an identity is to give unique numbers, not continuous.

Consider a situation where you have rows 1, 2, 3, and 4. If 1 is deleted, what's supposed to happen? If you reseed the identity it will get a number of 3 but that already exists...

If you need to show running row numbers, just use ROW_NUMBER (Transact-SQL) | Microsoft Docs[^] when querying.
Wendelius 16-Apr-17 6:39am View
Do not run the statements separately, instead, run them in a single batch.

If you're using Management Studio, you can for example select all the three lines and hit F5 to run the selected statements.
Mika Wendelius 15-Jan-17 9:03am View
If you get an error, post the error details. If you have a logical problem, post details about it and so on.
Mika Wendelius 15-Jan-17 6:41am View
When posting comments to solutions, don't post new solutions. Instead, press "Have a Question or Comment?" button.
Mika Wendelius 14-Jan-17 8:14am View
I mean that the query looks fine. If you have the database, just try to run it.
Mika Wendelius 14-Jan-17 5:38am View
Seems quite right. Depending on the database you use, it may be wrong to use AS for the table alias and some database use TOP and some LIMIT clause.
Mika Wendelius 14-Jan-17 3:14am View
How is the array related to the text boxes? Please add some more details and preferably code and data examples you have
Mika Wendelius 14-Jan-17 3:13am View
People here would expect to see some effort before answering questions. What have you tried, what exact problem you have, perhaps details about original data and desired output.

I suggest adding more details using the Improve question button.
Mika Wendelius 13-Jan-17 7:42am View
In case of an exception, do you write the exception to the log?

Also add rows to the log based on the program logic so that you can follow what the program has done by reading the log file. If we don't get some concrete piece of code and/or information about an exception, we're just guessing.
Mika Wendelius 12-Jan-17 9:35am View
You're most welcome :)
Mika Wendelius 12-Jan-17 8:50am View
Mika Wendelius 12-Jan-17 8:36am View
I restored the original version of the question.

If needed make the additions to the desired output, but also include the definitions how the amount of columns should be decided.
Mika Wendelius 12-Jan-17 8:14am View
Well, yesterday your output example was different, the same as in my answer...

If you need to have the data in separate columns then the amount of columns cannot be dynamic. So you basically need to decide how many columns you have in the result set before you run the query. The amount of columns cannot be different on different rows.
Mika Wendelius 12-Jan-17 8:09am View
I have to admit that my Java skills are in rust so I'm not entirely sure about the current situation. However it seems that table valued parameters are supported starting from JDBC 6.0 (MS). See Using Table-Valued Parameters[^]
Mika Wendelius 11-Jan-17 23:30pm View
Try adding logging to your code.

Catch any exceptions and, if needed, write details from the code in order to know which code is executed and so on.

Write this info for example into a file in C-drive or some other proper place. This will help you to get details about the problem and possible exception.
Mika Wendelius 11-Jan-17 23:19pm View
I'm afraid not. But if you are stuck at something or have other specific questions post them along with details and code as questions in Q&A and I believe that you'll get help to your problem.

Good luck.
Mika Wendelius 10-Jan-17 12:23pm View
Thank you.
Mika Wendelius 10-Jan-17 12:14pm View
Yes I see, using abstract classes would create kind of an index but I think it's an overkill because of the cost of inheritance (which somewhat also applies to interfaces)...

I'm still wondering if partial classes are good since you cannot define the same thing twice (in different files). The compiler simply merges the files and then compiles. If you for example have the same property defined in both files you get an error.

Anyhow, if you're interested, have a look at Multiple partial definitions for a class[^]
Mika Wendelius 10-Jan-17 9:33am View
Is this WebControls, Forms, WPF?
Mika Wendelius 10-Jan-17 6:11am View
See the updated answer
Mika Wendelius 10-Jan-17 5:54am View
Listbox isn't the same as textbox, they are completely different classes.

So are you trying to move items from a listbox in form1 to a listbox in form2?
Mika Wendelius 10-Jan-17 5:50am View
I'm afraid that's not telling much. What exactly isn't working and how? What are the exact steps you try and what error messages you get? Also please post relevant code parts if any.
Mika Wendelius 10-Jan-17 5:47am View
Please post the code you have for handling multiple elements.
Mika Wendelius 10-Jan-17 5:46am View
What kind of LINQ query you're after? Are you using Entity Framework and how? Please post an example of what you have tried.
Mika Wendelius 10-Jan-17 5:20am View
I see you have already opened a new question for this. That's good
Mika Wendelius 10-Jan-17 4:55am View
Ensure that the firewall isn't blocking the traffic. Go through the link I posted in the answer.
Mika Wendelius 10-Jan-17 4:54am View
See the updated answer
Mika Wendelius 10-Jan-17 4:41am View
The client that connects SQL server and the computer that is running SQL server and all firewalls in-between
Mika Wendelius 10-Jan-17 4:32am View
Sounds like the firewall is blocking the traffic. Ensure that proper ports are open on both ends
Mika Wendelius 10-Jan-17 4:26am View
You're most welcome :)
Mika Wendelius 10-Jan-17 4:18am View
In the connection string you need to specify the IP address along with the port. See Connect via an IP address - SqlConnection -[^]
Mika Wendelius 10-Jan-17 4:16am View
Added a new example
Mika Wendelius 10-Jan-17 4:11am View
As you can see in the code example I didn't select anything from the listbox nor did I use SelectedItem.

So to answer the question you need to make decision, what item indexes you move and then use the move code above in a loop where you replace 1 with the counter for the loop
Mika Wendelius 10-Jan-17 3:43am View
Why not? Of course you need to use your real list boxes instead of the lb1 and lb2. Those were created for demonstration purposes only.

If you run the code above and in the debugger examine the items in lb1 and lb2 you see that after running the code lb1 contains 2 items and lb2 contains 1 item.
Mika Wendelius 10-Jan-17 3:30am View
This doesn't really help.

Are you getting an error in the code? Are you having problems with the code on the calling side? Something else?
Mika Wendelius 10-Jan-17 2:31am View
That's a whole lot of code to read. Can you be more specific that you can't get the result?

Are you experiencing an error, if yes, what it is and at what line?
Mika Wendelius 9-Jan-17 23:54pm View
Please post the whole query in order to see the query structure.
Mika Wendelius 9-Jan-17 14:53pm View
Okay, the recursive function would basically handle that if you would have the following logic

for each row in datatable
RemoveNodesByText(row("county"), treeview1)

that would ensure that only the last remains.

However, this won't solve the situation for multiple columns. If you remove nodes also based on text in other columns, what if the combination of columns is unique, should it remain?

The more information you provide the more this sounds like you would need to modify the database query to return only unique combinations. For example if you now have

select county, city, state from mytable

you could use distinct keyword to remove duplicates when fetching the data:

select distinct county, city, state from mytable

This way you wouldn't need to remove already added nodes.
Mika Wendelius 9-Jan-17 14:34pm View
Note sure if I understand. Do you add a node for all rows that came from database and you want that only the last remains?

For example
- A fetched from database, A added to nodes
- B fetched from database, B added to nodes
- C fetched from database, C added to nodes
- B fetched from database, preivous B deleted, new B added to nodes
- and so on...
Mika Wendelius 9-Jan-17 13:19pm View
Based on your SQL it seems that the joins in my original LINQ query were invalid. I updated the solution.

Also check that the connection valid at the time you run the query, that you haven't closed it anywhere..
Mika Wendelius 9-Jan-17 4:46am View
As said you take the value from Calendar1 control in Calendar2 event handler. Is that the correct control? Also check the postback
Mika Wendelius 9-Jan-17 4:28am View
In general 20'000 rows in a table is small and you're fetching only 200 rows so everything should be fine. What I'm thinking of is that are the joins correctly in place so that you don't have Cartesian product. Can you post the generated sql?
Mika Wendelius 9-Jan-17 3:59am View
The comments are related on how you build the SQL statements, so you should have a look a them and fix the potential problems.

About the calendar I wrote a question if you are getting the date from correct control or not

What comes to state, it looks like you're not investigating if this is postback. Try modifying the code

if (!IsPostBack) {
Mika Wendelius 9-Jan-17 1:52am View
Few questions:
- how many rows you're trying to fetch?
- what does the generated SQL look like?
Mika Wendelius 8-Jan-17 11:09am View
Sounds good. The main thing is that you got it working :)
Mika Wendelius 8-Jan-17 8:17am View
Glad you got it solved :)

But I have to say that you could re-think the structure. I understand that the same table is used for different kinds of answer but still why store them in a single column. Could you modify the structure and have separate columns for separate data types?

As an example the feedbacktable could contain columns like
- feedback_date date
- feedback_int int
- feedback_string varchar(100)

This way you could always work with correct types and no worries from conversions :)

Good luck!
Mika Wendelius 8-Jan-17 8:04am View
So the data type is stored in a different table from the feedback? This could cause the problem.

If you run the following query
FROM FeedbackTable
WHERE (FeedbackTable.ClientId = 1)
AND (Feedback != '-')

Do you see rows that are not dates? If you do, these are potential conversion problems.

Then what happens if you add condition
AND ISDATE(Feedback) = 1
This requires that the format in the data matches your general date setting.
Mika Wendelius 8-Jan-17 4:58am View
But if you use the where clause in the outer query, it does not eliminate invalid rows from the inner query. So any row in the original table may cause the problem unless you place proper condition in the where clause of the inner query.

What comes to the age condition, as far as I can see the outer where clause is fine, it just restrict some of the rows the inner query returns.
Mika Wendelius 8-Jan-17 4:26am View
Did I understand correctly that this field is also used for other data than dates. So other rows may have values that are not convertible to dates?

If that is true, then the problem is that when you run the query, all rows in FeedbackTable need to be convertible to date. If even a single row contains a text value or something else, the whole query fails with conversion error.

If this is the case then you would need to add criteria in WHERE clause eliminating rows that are not convertible. Perhaps you already have a field defining the type of feedback and you could use that?
Mika Wendelius 8-Jan-17 3:34am View
Few things:
- What error did you get with format 105? 105 is for dd-mm-yyyy so could it be that the data isn't in this format?
- what error do you get when the WHERE clause is present?
Mika Wendelius 8-Jan-17 3:24am View
As I don't know the business requirements I can't tell if that is correct or not but I do have doubts.

Consider a situation where five rows are deleted. The trigger is fired only once and you fetch only one guid (the first one). After that you insert to TInfo_Performance_Queue using the return value from GetMaxEditionNo. So all the five rows have the same value for editionno.

Is this really correct?

If not, can you post details (code plus error) about the problem in the previous approach?
Mika Wendelius 8-Jan-17 3:09am View
Changed the solution a little bit to keep track of the changed properties...
Mika Wendelius 7-Jan-17 15:25pm View
So you want to prevent a second instance of the application from running. This requires a mutex. You need to examine if a mutex is already created and if not you reserve it. Each instance of your application does this check so only the first one is allowed to run.

There's a good post on the subject, have a look at c# - What is the correct way to create a single-instance application? - Stack Overflow[^]
Mika Wendelius 7-Jan-17 14:02pm View
But if you don't have code

new BatteryMonitorForm()

anywhere else but in Application.Run(new BatteryMonitorForm()); then you won't have two forms of that class...

What is the situation where you have 2 BatteryMonitorForm forms?
Mika Wendelius 7-Jan-17 12:24pm View
Why didn't the select work?

I modified the answer to include an example of using uniqueidentifier. The test runs without error but is your situation somehow different?
Mika Wendelius 7-Jan-17 12:18pm View
The form isn't found because you have placed the code in the beginning of the program where no forms are yet created.

The main method is typically run only once, when the application starts. at this point only one form is created using the Run method of Application class. So there is no way two similar forms can be created at this point inside a single application.

Can you explain the situation in more detail?
Mika Wendelius 7-Jan-17 10:07am View
Have a look at the modified answer.
Mika Wendelius 7-Jan-17 9:55am View
Which one is yes? Only one application or only one form inside an application?
Mika Wendelius 7-Jan-17 9:44am View
I'm sorry but I don't fully understand. Are the forms in different applications?

In other words are you trying to prevent an application from running if it's already executing or are you trying to prevent a form from opening twice inside a single application?
Mika Wendelius 7-Jan-17 9:41am View
When replying to a post, use the "Have a Question or Comment" -button. This way the original poster gets notified.

Deleting this solution might be a good idea since it's not actually a solution. Just hover over your solution and press the big red X :)
Mika Wendelius 7-Jan-17 9:39am View
To answer your question in Solution 2: "Can you give brief description on external access, safe,unsafe. In which Cases we have go with external access, or safe or unsafe".

Have a look at Creating an Assembly[^] I think that article explains the differences quite well. It's hard to say exact boundaries for external_access but many "low level" operations may use Win32 API and that would require unsafe.
Mika Wendelius 7-Jan-17 9:08am View
You're most welcome :)
Mika Wendelius 7-Jan-17 8:52am View
I'm not sure if I understand but when the window is maximized you can modify the controls as you like in the resize event. If you need to make modifications to the layout or to the content of the controls or anything else, simply add proper code.

I can't help you much further since I don't have the layout or the requirements. However, if you have specific problems, I suggest posting the relevant code parts along with a new question.
Mika Wendelius 7-Jan-17 8:31am View
I'm not sure if I fully understand but if you need to fetch data at the same time, simply write the code for fetching after setting the dockstyle.
Mika Wendelius 7-Jan-17 7:41am View
The query returns the full date range but if you want each of the dates to appear in a separate column when pivoted then you need to have a column definition in the PIVOT clause for all dates.

In other words if you want 2 dates you define 2 columns in PIVOT FOR IN. If you want 5 days you need 5 column definitions. So column definitions are not dynamic.
Mika Wendelius 7-Jan-17 7:16am View
Hopefully it works out :)
Mika Wendelius 7-Jan-17 6:31am View
The table is not a temporary table, it's a table variable so the scope is the batch it's declared in. No one else will see it.

What comes to the 'a' values in the insert statement, you used variables such as @environment or @status. In order to test the situation, I just replaced them with constants but you would use the actual variables.

I believe that the @mastertable need only the columns that are returned from the first insert. At least it looks like the variables you use are not coming from the build_master table but from your program.
Mika Wendelius 7-Jan-17 5:59am View
Have a look at the modified answer.
Mika Wendelius 7-Jan-17 3:10am View
In order for someone to help they would need to see the code that isn't working and specific information about the problem. Without seeing the code it wold be just guessing what might be the reason...
Mika Wendelius 6-Jan-17 13:23pm View
Seems that you already got the problem solved, that's great.

Concerning the deleted comments, I didn't take them as rude so don't worry about that :)
Mika Wendelius 6-Jan-17 6:11am View
Don't repost. If you need to make modifications to the question, use the Improve question link underneath the text to make changes.
Mika Wendelius 6-Jan-17 4:28am View
LIMIT clause will take the desired amount of rows but you should be ordering the rows first. Otherwise you may get the same rows twice or more

Also if you have 300 records for this week, what is the total amount of records in the table. That's what affects the speed. Because of that I wrote the suggestions in my previous comment.
Mika Wendelius 6-Jan-17 4:11am View
As far as I can see, in the SQL statement you have no criteria that would prevent sending the mail again and you don't have any sorting. So when you try to limit, you may get the same records again and if the table contains a lot of rows, then the time may be consumed by the query itself.

Having that said this sounds like query optimization issue. Few things to check:
- ensure that you have index on column week
- ensure that you have a proper primary key
- sort based on the primary key
- in the WHERE clause, add a condition to eliminate mails that are already sent
- if needed, add a column that holds information if the mail is sent or not
- add the newly added column to an index along with the week
Mika Wendelius 6-Jan-17 3:47am View
In order to answer your comment if I'm saying that this is impossible. No it's not but in most of the situations this would be a bad approach. Have a look at the updated answer.
Mika Wendelius 6-Jan-17 3:29am View
I'm sorry but I don't understand your concern. As said you need to
- have technical, secure connection between the computers (tcp/ip)
- you define the IP address and the port in the connection string
- you connect
Mika Wendelius 5-Jan-17 15:17pm View
Thank you.
Mika Wendelius 5-Jan-17 4:58am View
If CRMVIL01 is a separate database then the easiest way is to build a database link between the two separate databases and use that link to reference tables in the other database. See: CREATE DATABASE LINK[^]
Mika Wendelius 4-Jan-17 14:30pm View
Thank you Maciej!
Mika Wendelius 4-Jan-17 9:51am View
I understand that you're trying to use Visual Studio to connect but to get more details about the problem I suggest writing a short, simple code and try to connect to the Access database via code. This tells us if the connection can succeed or not and if the problem is in Visual Studio or for example in OleDb setup.
Mika Wendelius 4-Jan-17 9:48am View
Is CRMVIL01 a separate database or a schema inside the same db?
Mika Wendelius 4-Jan-17 3:30am View
What is on line 5, do you have more text in the editor than what you have posted here?
Mika Wendelius 4-Jan-17 2:38am View
If you're having problems with source code from a specific article then leave a message to that article. This way the author gets notified and may be able to help you.

If you think the problem is generic and could be solved by somebody else, then provide sufficient information such as link to the article and detailed information about the error.
Mika Wendelius 4-Jan-17 0:25am View
Exactly, you need the actual value from a row from the table. Glad it's solved :)
Mika Wendelius 4-Jan-17 0:24am View
Mika Wendelius 20-Dec-16 0:34am View
That's right. Your question sounds like your users are running data analysis queries in a transactional database (OLTP). If this is the case I would recommend building a separate database for reporting and transfer the data over there in a format easier to report.

Have a look at Data warehouse - Wikipedia[^] and Extract, transform, load - Wikipedia[^]
Mika Wendelius 19-Dec-16 18:21pm View
Can you provide an example situation
Mika Wendelius 12-Dec-16 0:48am View
Yes, I've thought about that and it could be a solution. Not directly comparable to other technologies where each inserted row can be linked to an object from the client side but with a little tweak it could work...

It really seems that there's no way to get the data back and that there's no guarantee for the order of the insertion. So calling BulkCopy is just one-way traffic in this sense. Funny.
Mika Wendelius 11-Dec-16 8:47am View
How would I get the generated keys back to client side for each row?
Mika Wendelius 11-Dec-16 7:49am View
Parallelism is always present with databases, you never know who's connected and doing what, so we just have to live with that :)

I can work around this problem by using other approaches, but I'm just interested if this requirement can be satisfied with bulk copy.
Mika Wendelius 11-Dec-16 6:29am View
Thanks for the suggestion but I'm afraid that wouldn't work. There's no way to control parallel operations so the TOP query could return rows that are inserted by another, simultaneous connection.
Mika Wendelius 11-Dec-16 4:59am View
You're most welcome :)
Mika Wendelius 10-Dec-16 6:53am View
When you have a look at the line

file.FileData = (byte[])(drUserDetails["FileData"]);

Does it assign the correct data?
Mika Wendelius 8-Dec-16 23:58pm View
It would help if you can post example source data along with desired output.
Mika Wendelius 7-Dec-16 15:59pm View
What is the problem you're having?
Mika Wendelius 29-Nov-16 16:17pm View
What is the code for saving the URL into the database?
Mika Wendelius 28-Nov-16 11:13am View
You're most welcome :)
Mika Wendelius 28-Nov-16 9:49am View
Try using the debugger, what is the value in count when you execute the following line

finalPointArray = new int[count];
Mika Wendelius 28-Nov-16 9:13am View
To get more information about the reason for the exception place a breakpoint on the line

FileStream fs = new FileStream(imgloc, FileMode.Open, FileAccess.Read);

Does imgloc contain a correct value. If it does, repeat the same with

FileStream fs1 = new FileStream(imgloc1, FileMode.Open, FileAccess.Read);

Also investigate the exact row that is causing the exception.

When this is done you know more about the reason for the error and if it is that either of those variables contain invalid path.

When this is fixed concentrate on using parameters for the query and implement the using blocks and the try..catch blocks.
Mika Wendelius 27-Nov-16 15:35pm View
Take is executed in a different phase that you're expecting. The individual grouped row is evaluated before the take operation.

Have a look at the execution with the debugger, go through the original query line-by-line. I believe that it'll help you to see how the evaluation is done :)
Mika Wendelius 27-Nov-16 14:28pm View
:) That is very true.
Mika Wendelius 27-Nov-16 13:30pm View
See the updated answer.
Mika Wendelius 27-Nov-16 13:27pm View
Instead of posting a new solution always use the "Have a Question or Comment?" to comment on given solutions. This way the author of the solution will be notified.

Having that said, have a look at updated solution 1
Mika Wendelius 27-Nov-16 13:16pm View
On what line the exception is thrown?
Mika Wendelius 27-Nov-16 13:02pm View
When you debug the code and you hit the line

finalPointArray[m] = 1;

what is the value of count and what is the value of m
Mika Wendelius 27-Nov-16 13:01pm View
I can't fix your code. I don't have the project nor the data nor the requirements and most importantly you wouldn't learn from it.

So you need to get the pieces together but people can help you as long as you try and have good questions.

Having that said, you currently seem to loop all the rows in the gridview. However, you make the decision whether to update or insert based on a selection of a combo box (comboBox1). That combo box has only one selection so could the reason be that even though you loop through several rows the decision whether to update is always the same. In other words is the logic incorrect.
Mika Wendelius 27-Nov-16 11:17am View
I don't mean that you should use a foreach in an update. Update commands updates an existing row. In the example you posted you had a foreach loop where you decided if you update or if you insert a row. The insert command was suffering from the same kinds of problems as the update command so have you fixed that already?

Also the decision whether to update or insert a row was made using a select statement. Have you debugged if the select statement works as expected?
Mika Wendelius 27-Nov-16 11:10am View
That updates a single row, how do you insert two rows? Do you still have the same foreach loop as in the code in the question?
Mika Wendelius 27-Nov-16 11:03am View
What is the code you currently use?
Mika Wendelius 27-Nov-16 10:58am View
Not quite sure what you mean. If you get error message, please post it or some example data for the problem.
Mika Wendelius 24-Nov-16 14:30pm View
What is the exact error you get?
Is it from Crystal or from SQL Server?
Mika Wendelius 23-Nov-16 13:00pm View
That's good to hear! Sounds like a nasty problem and I hope you get it working properly. All the best!
Mika Wendelius 23-Nov-16 9:21am View
If I understand the question correctly, yes you can use the same idea also with inserts. You could create a static method that executes the insert and gets the person as parameter. The signature would look something like

public static Person InsertPerson(Person personToInsert) {

However, it could make more sense not to make the method static. When you're fetching a person, you don't actually have the person thus having a static method id feasible. But when you insert a person you have already filled all the properties and you must pass the instance of the Person object for inserting. So why not define the insert as part of the person instance. In other words

class Person {
public bool Insert() {
... code to insert ...

In this case the call would be something like

Person person = new Person();
person.FirstName = "...";
person.LastName = "...";
if (!person.Insert()) {
... inform about a problem ...
Mika Wendelius 15-Nov-16 6:37am View
Yes it seems to be the same. As you can see there's two minutes difference so we seemed to write the solution at the same time.

Glad that you got it working.
Mika Wendelius 6-Nov-16 2:42am View
Nice example, a 5.
Mika Wendelius 5-Nov-16 5:00am View
Glad if it worked out!
Mika Wendelius 5-Nov-16 4:33am View
Glad you got it worked out!
Mika Wendelius 4-Nov-16 12:08pm View
In your example, what is the expected output?
Mika Wendelius 3-Nov-16 15:34pm View
And when you debug this the dt is empty and no exceptions?

Also if you take the exact same query and execute it in Firebird the data is returned?
Mika Wendelius 3-Nov-16 14:49pm View
What is the C# code you have?
Mika Wendelius 3-Nov-16 13:52pm View
I tried this on an example Excel and it worked fine. Are you sure that the delimiter is a blank space? Try to debug and see if the InStr returns correct value for each cell.
Mika Wendelius 2-Nov-16 2:53am View
You're most welcome :)
Mika Wendelius 2-Nov-16 0:14am View
Glad to be of service :)
Mika Wendelius 1-Nov-16 2:02am View
Few questions, why do you want to remove columns from the data table and what is the problem you're facing with your code?
Mika Wendelius 31-Oct-16 16:48pm View
Good example, a 5.
Mika Wendelius 31-Oct-16 16:40pm View
Have a look at the example @RichardDeeming wrote. It's a good example how you should write the code. As far as I can see using i++ or ++i is not the problem so why not let it be as-is.
Mika Wendelius 31-Oct-16 11:27am View
That behavior is by design. If I recall correctly, it was introduced in 2008. The idea is that if you have free memory, why not use it. If memory is needed by another application SQL Server also releases it's memory reservations as long until the minimum is reached.

So basically this shouldn't be the cause for the behavior unless freeing memory gets slow, but I can't see any reason for that unless the server is under heavy load or you typically have a lot of uncommitted data.

However, I'd be interested in hearing if this really solved the problem!
Mika Wendelius 31-Oct-16 5:52am View
Is there any specific reason you had in mind? I'm asking this since the technology to choose always depends on the requirements.
Mika Wendelius 30-Oct-16 15:10pm View
Testing comments, just ignore this.
Mika Wendelius 30-Oct-16 15:08pm View
You're most welcome :)

There are a lot of different guidance and best practices but I believe that they are more like material from which to learn than exact instructions how to do something. So depending on the situation the best solution may vary a lot.

One thing that comes in mind is that you could separate the entity for the data from the logic how to fetch the data. One simple way could be just to split the person class to two partial classes. The other part would contain only the properties for storing the data while the other part would contain logic.
Mika Wendelius 30-Oct-16 15:08pm View
You're most welcome :)

There are a lot of different guidance and best practices but I believe that they are more like material from which to learn than exact instructions how to do something. So depending on the situation the best solution may vary a lot.

One thing that comes in mind is that you could separate the entity for the data from the logic how to fetch the data. One simple way could be just to split the person class to two partial classes. The other part would contain only the properties for storing the data while the other part would contain logic.
Mika Wendelius 30-Oct-16 11:25am View
Please post the exact error message you get and information on where it's thrown.
Mika Wendelius 30-Oct-16 11:22am View
I think the best option is to gather data and report to Microsoft if the findings show a problem. Does the memory consumption grow constantly when the query is ran, what happens when the SQL Server is restarted, what do the meters in performance monitor show and so on. If this really is a memory leakage, then MS should have a fix for it.

I tried to find info about such situations but couldn't find anything that matches. It still could be a known problem after all.
Mika Wendelius 30-Oct-16 8:45am View
If it's slowing down bit by bit, it could indicate for example a memory leak etc. Because of this the main memory could become the bottleneck and cause for example swapping. These are the things you would see when monitoring the server performance. After all there has to be a reason for the slowdown.
Mika Wendelius 30-Oct-16 7:18am View
Still seems quite unclear. Can you post an example data for the problem and explain a bit more what difficulties you're experiencing.
Mika Wendelius 30-Oct-16 5:20am View
How the loading is done? Do you use SSIS, do you have a stored procedure, a separate program, or something else?
Mika Wendelius 29-Oct-16 14:51pm View
You mean you don't want to repeat province name if it's the same as on the previous row? If that's the case, have a look at How to Format Repeating Values in SQL Result Set[^]
Mika Wendelius 28-Oct-16 10:52am View
What is the common factor for the breaks on a single row? Is it for example theat they are on the same date?

What happens if there is only one break or if there are three breaks or more for the same day? How should these be shown?
Mika Wendelius 26-Oct-16 11:00am View
You're welcome :)
Mika Wendelius 25-Oct-16 14:58pm View
You're most welcome :)
Mika Wendelius 25-Oct-16 13:49pm View
If you have tried OPENROWSET, what was the problem with that?
Mika Wendelius 24-Oct-16 17:14pm View
The example data doesn't look like it's directly from the SQL statement since it's already formatted differently. But more importantly, what client technology you use, Forms, WPF, ASP?
Mika Wendelius 24-Oct-16 10:34am View
Can you post an example case?
Mika Wendelius 22-Oct-16 4:47am View
Can you explain a bit more, what you're trying to do and what problems you have
Mika Wendelius 22-Oct-16 4:30am View
Not copying all of the files could well cause this, a 5.
Mika Wendelius 21-Oct-16 13:49pm View
Thank you.
Mika Wendelius 21-Oct-16 13:49pm View
Nice example, a 5
Mika Wendelius 21-Oct-16 10:56am View
You didn't explain the problem. If the problem is still the same, modify the INSERT statement to include all the columns you need to fill and also provide values for all these columns.

If you need further help, post the current SQL statement you have, the error you get and definition for the table.
Mika Wendelius 20-Oct-16 15:34pm View
The post doesn't contain table Bandwith and it doesn't contain declarations or manipulations of @SwitchIP and so on. At least when I tried I couldn't make the example work.
Mika Wendelius 20-Oct-16 14:52pm View
Thanks :)
Mika Wendelius 20-Oct-16 14:50pm View
Is the actual user identified by SQL Server or do you have your own user management tables?
Mika Wendelius 20-Oct-16 14:27pm View
Can you provide a small test case in order to reproduce the behaviour?
Mika Wendelius 20-Oct-16 13:35pm View
Are you using Bison?
Mika Wendelius 19-Oct-16 11:04am View
What is the thing you're stuck with? Please post any relevant code.

Also what is the point of sending the encrypted file in an email with the password?
Mika Wendelius 18-Oct-16 2:18am View
If you want to do formatting on the grid, have a look at DataGridView.CellFormatting Event (System.Windows.Forms)[^]
Mika Wendelius 18-Oct-16 2:17am View
Why would there be invalid keys? I understand that you currently may have inconsistent data but cleaning it up is a one-time operation. After that the foreign keys should take care of the consistency. What comes to cleaning up, as said, you can use sp_fkeys to resolve existing references
Mika Wendelius 17-Oct-16 23:21pm View
Mika Wendelius 17-Oct-16 14:30pm View
Glad if it helped. However, note the comment on storing passwords.
Mika Wendelius 17-Oct-16 10:14am View
I'm not sure if I follow, but as I said previously, personally I would use a single database for all years and a single table also. So I wouldn't separate the data based on the year.

I'm not sure why you're worried about a 2GB backup size. With current disk sizes, 2GB is hardly nothing, far less than a DVD.

My point is to keep everything as simple as possible from programming point of view and let the database do it's job, handle the data properly.

But as also said there is no single best solution because of different affecting factors so you have to gather information, consider different options, and make the decision based on all requirements you may have.
Mika Wendelius 16-Oct-16 13:11pm View
Not sure what you mean by clearing the previous database year, but if you want to retrieve values only from current year, then that would be a condition in the SQL statements. For example if you have a RowAdded column in a table then you would have a comparison that RowAdded is greater than or equel to first day of the year.

But again having data for current year only seems a bit odd requirement for an ERP system.
Mika Wendelius 16-Oct-16 13:08pm View
Consider a situation where the original data would contain a value 'UNKNOWN' for product code. Your code relies on the fact that UNKNOWN isn't found in the original data and this value is always generated becuse of NULL.

Now, if the 'UNKNOWN' would suddenly appear in the original data you would falsely interpret it the same as NULL since you convert NULL to text UKNOWN. In such case your code would return all rows having product code
- 89ABHS

Because of this comparison with IS NULL or IS NOT NULL is safer since there are no assumptions.
Mika Wendelius 16-Oct-16 9:48am View
That is something you should go through with an authorized re-seller. Licensing is complicated and has a lot of affecting factors.
Mika Wendelius 16-Oct-16 8:02am View
There seems to be no code which explains the Result() method.

Also a clarification you are missing rows? Not columns?
Mika Wendelius 16-Oct-16 4:30am View
How the result is returned. The filtering is most likely done in Result method so you should also post that code.
Mika Wendelius 16-Oct-16 3:36am View
Nice answer, a 5.
Mika Wendelius 16-Oct-16 3:33am View
Thank you :)
Mika Wendelius 15-Oct-16 11:48am View
Good points,5!
Mika Wendelius 15-Oct-16 11:48am View
So you can connect but executing the statement fails. What is the SQL statement you try to execute?
Mika Wendelius 15-Oct-16 7:11am View
Do you get the error message "Could not find file" when you connect to the database or when you execute an SQL command? If this happens when executing a command, what is the SQL statement?
Mika Wendelius 15-Oct-16 6:27am View
Thank you Maciej!
Mika Wendelius 15-Oct-16 6:03am View
Is the path correct? Is the ACCDB file located in C:\ ?
Mika Wendelius 15-Oct-16 2:34am View
If I understand your question correctly the vwOrdersforManageUsers is a view. If that's true, please post the query that is used to create the view.
Mika Wendelius 15-Oct-16 2:30am View
Glad if this was helpful. With the driving table I actually didn't mean that you would separate current and historical locations. Only that you would have a lookup table containing one row for each truck and it's primary key (truckid).

What I suspect is that if you would have such table and use it in the query, the database could use it as a lookup table and possibly do an index join to fetch the locations more quickly.

Perhaps worth a try...
Mika Wendelius 15-Oct-16 2:30am View
Glad if this was helpful. With the driving table I actually didn't mean that you would separate current and historical locations. Only that you would have a lookup table containing one row for each truck and it's primary key (truckid).

What I suspect is that if you would have such table and use it in the query, the database could use it as a lookup table and possibly do an index join to fetch the locations more quickly.

Perhaps worth a try...
Mika Wendelius 10-Oct-16 9:10am View
Also if you need to calculate difference between two datetime's, use DateTime.Subtract Method (System)[^]
Mika Wendelius 10-Oct-16 9:08am View
If the receiving variable is DateTime, don't use solely ToString method, instead use DateTime.Parse Method (System)[^] or simply cast the object from the datareader to DateTime using CType Function (Visual Basic)[^]
Mika Wendelius 10-Oct-16 3:48am View
Converting join directly to union yields to different results. What is it you're trying to achieve?
Mika Wendelius 10-Oct-16 2:33am View
How does method SqlHelper.UpdateDataset look like?
Mika Wendelius 10-Oct-16 1:25am View
Using debugger verify that you don't simply call the C# method twice
Mika Wendelius 10-Oct-16 1:00am View
Do you get any other error messages, any inner exceptions?
Mika Wendelius 10-Oct-16 0:11am View
The OP's comment was most likely meant for you also so if you have ideas please comment.

Thanks! check those two suggestions.
it`s a solution for current handeled files\modules.
im looking for previous handeled file by a process.
for example:
1. a process helloworld.exe loaded.
2. the process creating a file - "testfile.bat"

I want to know that testfile.bat was created by helloworld.exe.

hope im more clear.
Thanks :)
Mika Wendelius 9-Oct-16 23:27pm View
As far as I know, the information, which program created or modified a file, isn't available in Windows after the process has closed the file. The only way is to make observations when the file is open by a process.
Mika Wendelius 9-Oct-16 23:21pm View
What do you want to achieve?

If you just want to eliminate the NULL records from the result set, add the IS NOT NULL condition to the where clause.
Mika Wendelius 3-Oct-16 14:47pm View
Have a look at the examples added
Mika Wendelius 1-Oct-16 14:49pm View
That's good to hear :)

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid