Click here to Skip to main content
15,354,171 members

Comments by dbrenth (Top 24 by date)

dbrenth 12-Sep-19 8:04am View
Also don't keep closing and opening the connection. At the end of the using statement the connection will be closed automatically. It can remain open throughout the using statement.
dbrenth 12-Sep-19 8:02am View
If this is an exact copy paste then you need to fix your parameter names:

String query = "UPDATE TData SET agent_shortname =@agentanalysiscode WHERE company_code=@companycode";
SqlCommand cmd3 = new SqlCommand(query, conn1);
cmd3.Parameters.AddWithValue("@company_code", Convert.ToString(mapping.companycode));

In the first line it is @companycode and in the last line it is @company_code
In both places in your code. These need to match.
dbrenth 23-Mar-17 16:50pm View
For the best shot at getting answers, please provide your table structure and some sample data. It is impossible to know given this information how to help.
dbrenth 30-Nov-16 16:19pm View
You did not include your error messages.
dbrenth 30-Nov-16 16:14pm View
What do you get when you run the SQL in the native SQL Server Management studio? It is possible you may need to qualify your table name. Make sure you log into Studio using the same user as in your connection string.
dbrenth 17-Mar-16 13:29pm View
Thanks, I was simply hoping that wasn't the answer. But I understand why.
dbrenth 17-Mar-16 13:24pm View
This kind of thing might be possible if the method in class A were public instead of protected. I can't change class A. Since it is protected, I can't access it except through class B.
dbrenth 2-Mar-15 13:57pm View
Given this data you can do this:

select c.clientid, company, c.product, total, rcvamt, restamt
from DBHTestCustomer c left outer join
DBHTestPayment p on c.clientid = p.clientid

or, if you want to calculated it in the SQL, this:

select c.clientid, company, c.product, total, sum(rcvamt), min(restamt)
from Customer c left outer join
PaymentData p on c.clientid = p.clientid
group by c.clientid, company, c.product, total

Either one turns the above given data into your report.
dbrenth 23-Jul-14 13:21pm View
So, what is RegistrationInfoSettingXref? Is there an insert trigger that writes to PluginSettingXrefValue?
dbrenth 11-Jun-14 8:54am View
Why does it have to be in LINQ? You could:
1. Create a view on the SQL Server and load the view.
2. Call the SQL directly from your program and load a data table.
3. Use LINQ to do the where clause, then post process to get the distinct items with 3 instances.
dbrenth 7-Mar-14 8:27am View
Because without it, you get that one and the '05 mar 2014' lines - which you don't want.
dbrenth 6-Mar-14 16:29pm View
What is the reason for the "constraint"? Is this a homework assignment?
dbrenth 20-Feb-14 11:25am View
SQL Server Management Studio is very good at determining what indexes are missing and even gives you the script for creating the potential missing indexes (at least in version 2012). Enter your long running sql query and run Query -> Display Estimated Execution Plan.
dbrenth 6-Jan-14 13:57pm View
You can pepper your procedure with select statements so it will give you feedback while it runs. This would be most helpful. We can't see what is in the Student table so it is hard to say.
dbrenth 5-Dec-13 14:11pm View
I must be misunderstanding something. To know which specific row has been changed, just look at the WHERE clause in your SQL statement.
dbrenth 26-Nov-13 15:51pm View
Have you tried catching the Adpater's RowUpdated event and seeing what messages appear there?
dbrenth 23-Apr-13 16:37pm View
I wouldn't try to do it on a table level. You can probably mess with triggers, but triggers can be fragile. They have to be in every table that touches your data in insert update and delete functions. And if you have a bug in your calculation, good luck - it could be in any one or more of the triggers.

Using a view allows you to maintain the calculated information in one place as if it was a table. And the calculations are in one place.
dbrenth 23-Apr-13 16:28pm View
I don't understand your comment about views. The purpose of a view is to display data with computed or renamed columns. They do allow multiple tables and functions, but you can't update or insert through a view with multiple tables and functions. You have to insert or update the base tables, and then the view with its calculated columns will update automatically.
dbrenth 28-Mar-12 8:37am View
The other option is redesign. You can't afford not to use parameters. You owe it to your client to deliver a product that's safe.

I recommend building your query into stored procedures. Stored procs can take comma delimited strings as an argument. And you can pass the argument in as a parameter. Or you can generate the sqlcommand dynamically as ... ItemCode = ? or ItemCode = ? or ItemCode = ? ...

If you stick with what you have, the special characters will be the least of your problems.
dbrenth 16-Mar-12 9:29am View
GetDate() is a function that doesn't run on any table. It is a function that just places the current date into the list of insert values.
dbrenth 20-Sep-11 16:35pm View
I usually skip the DataSet and go straight to the DataTable.

DataTable dt = new DataTable();

Now you just index through the rows and columns in the DataTable.
dbrenth 24-May-11 13:47pm View
I am just warning you of potential sql injection attacks. You may want to look at using SqlParameter's instead of just blindly throwing in whatever a user types in at the text box.

Anyway, do you get a better result when you try command.ExecuteNonQuery();?
dbrenth 24-May-11 13:30pm View
Please define "it doesn't work well for me." That could mean anything, Including that the table keeps disappearing everytime you enter "' DROP TABLE MS4 --" in the textbox.
dbrenth 4-Apr-11 16:35pm View
In that case I withdraw my solution. I think you will have to parse the Body string and save it out to a file with a good old fashioned Stream function.