15,886,693 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by dbrenth (Top 28 by date)
dbrenth
2-Nov-23 13:41pm
View
I don't see where you have initialized the variables "server", "database", "username" and "password". When you set a string with the $ prefix, the parts in {} will be replaced with the variables or functions inside the brackets. If there is nothing, NULL will be returned and that could be your NULL that is causing the Invalid Cast Exception.
dbrenth
5-Jul-23 15:11pm
View
I answered the question with the assumption that they didn't have the ability to alter the table. And also as a challenge to myself to see if I could actually do it in a single SQL statement. I agree it is far from ideal for performance and maintenance.
dbrenth
7-Dec-22 11:55am
View
The Interop Libraries require Word to be installed. And you cannot correctly open a word document without the interop libraries. So probably not.
dbrenth
7-Dec-22 11:54am
View
To be fair to the OP. Your link takes you to a page with broken links and other links that require Word to be installed (against his requirement). I think it would be more helpful to direct him to a google page that says "You cannot use the Interop libraries without Office installed." And the interop libraries are required to correctly read a word document.
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();
sqlDataAdapter.Fill(dt);
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.
Show More