Tag: c#

Passing a function as a parameter in injecting data into SQL Server

I wrote a GetLoan function: private void GetLoan(RadioButton radiobutton) { if(radiobutton.Checked) { MessageBox.Show(radiobutton.Text); } } and in order to get the necessary data from the radio button I did this, bookCom = new SqlCommand(“UPDATE d_Book SET ISBN = @isbn, Author = @author, Title = @title, Publisher = @publisher, Date = @date, Loan = @loan WHERE […]

Can we create format file from bcp command line as a different field terminator for each field?

We are using non-XML format file to import data into Sql Server database through bcp utility. We have used comma(,) as a field separator in the bcp. Now we are getting issue when user provides comma(,) between the string field like name. Field get terminates by comma(,) and rest of the words goes in to […]

How can i implement row or table locking using visual studio 2015 ?

I want to add in multi-user access feature whereby concurrency wont occur in my web application, is there any method that is easy and simple to implement ?

DateTime gives error with table types sql c#

I have the following lines of code: //Function that returns the following metadata List<SqlMetaData> data = new List<SqlMetaData>(); data.Add(new Microsoft.SqlServer.Server.SqlMetaData(“Id”, SqlDbType.BigInt)); data.Add(new Microsoft.SqlServer.Server.SqlMetaData(“Name”, SqlDbType.NVarChar, -1)); data.Add(new Microsoft.SqlServer.Server.SqlMetaData(“Description”, SqlDbType.NVarChar, -1)); data.Add(new Microsoft.SqlServer.Server.SqlMetaData(“Date”, SqlDbType.DateTime)); //Function that builds the record and fills it with data SqlDataRecord record = new SqlDataRecord(data.ToArray()); record.SetInt64(0, this.Id); record.SetString(1, this.Name); record.SetString(2, this.Description); if (this.Date.HasValue) […]

Unable to insert data into SQL Server Database ODBC C++

I have been trying to insert a record into the sql server database using odbc but having some issue.The program below is code using a console c++ on visual studio. #include “stdafx.h” #include <iostream> #include <Windows.h> #include <sqltypes.h> #include <sql.h> #include <sqlext.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { RETCODE rc; HENV henv; […]

how to use inner join in sql and print data?

I try to learn SQL, I try to print data from table 1 by using inner join concepts in SQL but I can`t my table 1 name is “Assets” and my table 2 name is “AssignAssigneeMapper“ My database name is MyDataBase First table columns are (Assets) assetId int (Identity), assetName varChar(100), modelNo varChar(100), price decimal, […]

SSIS package fails on file.delete of script task

I have an SSIS package, zip.dtsx. This package successfully runs on serverA. I copied this package in serverB. However, when I try to run zip.dtsx on serverB, it fails. zip.dtsx just reads a file in a source folder, compresses it, saves the compressed file to a different folder, then deletes the original file in the […]

What is the best way to handle DateTime in a Web Application?

I’ve been doing some research around on how to properly store and save the Date and Time in a Web Application but I couldn’t find a post that has a marked answer. I have a ASP.NET MVC website and I use C# for backend code and MS SQL for the database, let say you have […]

I have created a generic database class to call database (SQL Server) from C#

I am new to .net. Please help me what the things should I add here? How to add stored procedure? My aim is to keep DataAccess class in one project and use it in other project as .dll. In other project I just want to call dbclass and to add parameter, execute method only. Please […]

.NET C#: How to dislay foreign key property?

I have this model called Station and ServiceLevel. Station contains a foreign key called ServiceLevelId which refers to a primary key in the ServiceLevel table. But I can’t show the ServiceLevel properties which is a part of the Station. I can present the station properties in the view by writing: @Html.DisplayFor(model => model.Name) But it […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.