Tag: c#

Cannot get SQL error message

I am tring to run a sql script from my c# application string sql = File.ReadAllText(sqlFile); string[] QueryArray= sql.Split(new string[] { “GO” }, StringSplitOptions.RemoveEmptyEntries); foreach (string query in QueryArray) { cmd = new SqlCommand(query, Connection); cmd.ExecuteNonQuery(); } Then my script contains raiserror statement RAISERROR (‘Cannot procees’ , 20, 1) WITH LOG When I try to […]

Issue while implementing Entity Framework 6.0 in VS 2012

While implementing Entity Framework 6.0 in VS 2012 (i.e. creating edmx file & tried to generate my Model class out of it), I got below error message (even though Test Connection to DB is succeeding). The ‘SqlStudio Profile Package’ package did not load correctly As a resolution step I tried to re install “Microsoft SQL […]

Updating Parameters In Data Source for a Report Viewer ASP.NET C#

I have the following controls: Data Source, Report Viewer, and two Telerik RadDateTimePicker. Screen shot of what my Rad Controls look like. My report is a client report definition (.rdlc). I have a stored procedure in my SQL 2008 database that I am using for the report, and the data source. I have configure with […]

How can I update my SQL table in C#?

I created a program that requires a database and I am using Visual Studio and SQL Server to do it. My problem is that I cannot update my table. I found the solution here. My code is below: this.customersTableAdapter.Update(this.northwindDataSet.Customers); tabelAdapter.Update(ABCDatabaseDataSet**.Barber)**; But it gives me an error that the ABCDatabaseDataSet does not have Barber. There is […]

Data Input asp.net C# SQL

Hey guys I am using a connection string database set-up inside visual studios 2012. I am trying to send data to the database there are no errors in the code but its not running, any help would be fantastic as i have been at it for a few hours now and need some sleep. Thanks. […]

SQL Server 2012 XML Type Preserve Significant Whitespace

I am trying to store some data in an XML-Typed Column which, when the data is a string, will preserve the exact text and not replace or adjust embedded line-endings specifically CR & LF. So a C# string like “A\r\nB\rC\nD” needs to come back exactly so but it would appear that the XML conversion insists […]

razor set value of variable created by .query() method

I have used the following code to get one more than the biggest ID in a table using razor @foreach (var top in db.Query(“SELECT MAX(ID)+1 as ID FROM mytable”)) { if (@top.ID == null) {@top.ID = 1; } } if the table is empty, @top.ID returns null. I am trying to set its value to […]

Save Image into sql server or inside the folder name Images in web application

I have one save button which will save the image in the desktop from camera when button is click below is the code….. <input id=”Save” style=”Z-INDEX: 1; LEFT: 8px; WIDTH: 128px; TOP: 36px; HEIGHT: 24px” onclick=”return save_onclick()” type=”button” value=”Save Image” name=”save”> function save_onclick() { document.AxuEyeCam.SaveImage(“test.jpg”); } It not good to save image in one pc […]

NHibernate and MS SQL function NEWSEQUENTIALID() to generate an ordered GUID

How can I configure NHibernate 3.3.1 (or some other version) to allow Microsoft SQL 2008 R2 to generate the primary key value (guid that is ordered) for a table with data type uniqueidentifier and default constraint NEWSEQUENTIALID()? My testing has shown that I can setup the Id (PK) mapping as GeneratedBy.Guid.Native() but this will call […]

Move all database tables under another database with new Schema?

So I’ve been tasked with researching something I’ve never done before. 3 Application modules built using C# in VS2010 are using 1 database (Database1) with the tables such as dbo.Samples, which all have the schema “dbo.Table“. For some higher-up unknown reason, it has been requested that all these tables under Database1 be moved into Database2 […]

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