Relative Content

Tag Archive for c#sql-server

Why is my C# code not updating the database record and row not select properly?

I am working on a C# application on Adding Admin to the database. I can select a data row from a grid, and the details of the selected row are displayed in textboxes for editing. However, when I change the textboxes and click the “Update” button, I receive the error message: “Select a record to update” even though I have already selected a row and the details are displayed correctly in the form. My SQL server works properly.

Define constraint to prevent values outside the smalldatetime range from being inserted into a DataTable (C#)

I have a CSV file with different values. I have loaded these values into a DataTable, which has the same structure as a table in SQL, with the difference that the table in SQL has smalldatetime fields and those of the DataTable are of type DateTime. The structure of the DataTable is created dynamically according to certain user requirements.
Once the data has been loaded into the DataTable, I perform a SqlBulkCopy to copy the data from the DataTable to the table in SQL, but the process aborts (DataTable SmallDateTime overflow) because some values that exist in the DataTable are not in the range “1/1/ 1900 12:00:00 AM and 6/6/2079 11:59:59 PM”

C++ MSSQL query returns string like “MMMMMMMMMMMMMMMMMMMMMMMMM” if field in DB is NULL

I am creating a c++ program to work with a mssql database. I connect to the base with the code described in this video https://www.youtube.com/watch?v=1g_Xng_uH2w&t=835s. However, I encountered one problem. When the database field is NULL in the query response I get one big string of something that looks like “MMMMMMMMMMMMMMMMMMMMMM”. Can anyone tell me how I can change this. The best option is for my request to return NULL.