Tag: c#

Pass Dynamic Data Table to Ms sql Stored Procedure

I have a scenario where am uploading a Dynamic (some columns vary but I had to maintain their names in a table each time a user requires it, but it is not predictable so what i check is whether the column name is maintained) Excel document and saving the content using Linq. Unfortunately due to […]

Is it possible to create read-only synonym in SQL Server?

We have 2 different databases DB1 and DB2 with tables in DB2 referring to tables in DB1. We are looking into the possibility of using SYNONYMS with read-only access in DB2 and use EntityFramework to refer to these SYNONYMS as tables in DB2. Since currently EF doesn’t span across multiple databases, after reading this article […]

Linq to SQL Delete/Add Child objects

I have a customer table which has a child table called customer addresses. Customer: CustomerID Name IsActive CustomerAddresses: CustomerAddressID CustomerID Street City State ZipCode I would like to update the customer table with a list of customer addresses and have it automatically remove/add the entries if they already exist. Does linq to SQL do this […]

Issue with SQL Server database in Registration form Visual Studio

This is my code: private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@”Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Dido\Documents\DataCars.mdf;Integrated Security=True;Connect Timeout=30″); SqlCommand cmd = new SqlCommand(“insert into Login values(‘” + textBox1.Text + “‘,'” + textBox2.Text + “‘)”, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); if (!String.IsNullOrEmpty(textBox1.Text) || !String.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show(“Your registration was successfull!”); Login frm1 = new Login(); Global.GlobalVar = […]

Get Data from GridView into DataTable in C# WebApp

I am working on a webapp that currently has a GridView binded to MSSQL. The GridView correctly displays the data from the database, and I have made one of the columns to be displayed in a textbox. What I am trying to do is, to get the changes that the user made to the data […]

how to import excel to sql unknown data

How to Import unknown data recorded from excel to SQL Server I have a C# web-based project that the users must upload a excel sheet and I need to store the data from that excel sheet to the SQL Server. there is a note that the users records is unknown and please show me a […]

How to set one column true which will make all other entity value false in sql?

I have a column in a user table as IsAdmin bit. There can be only one person admin at a time. Therefore, What I would like is to constraint the table to set all other users IsAdmin value to false on setting one user true? I can achieve this by going one by one to […]

How to fix – Cannot find object/table in database error when it actually exists?

I made a console C# app in which I generate SQL to insert a row into a table info_table and then execute it. When I use the same C# code (with necessary modifications of course) in SSIS, I get an error saying that the table cannot be found. Error: System.Reflection.TargetInvocationException: Exception has been thrown by […]

How to generate an MDX query automatically using c#

I have a table named calculation looks like that idPnl id operator 12 13 * 12 14 * 12 15 * 20 1 – 20 2 – 13 21 / 13 20 / I am looking to generate mdx query automatically using script c# and write it in a text file : Example the script […]

Firebird functions from Visual Studio DataSet?

I’m having an issue trying to convert some code from MSSQL to Firebird (don’t ask) and wondering what I am doing wrong? MSSQL: DAY(timeofevent) as MyDay Converting to: Firebird: EXTRACT(DAY FROM timeofevent) – causes errors because VS complains about the ‘FROM’ here and also it changes the function to read: “extract” ( “day” from timeofevent […]

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