Tag: ado.net

Execute multiple stored procedures with single trip to database

I have a lot of legacy data access code mainly SqlCommand with Stored Procedure calls that we used to execute alot of Insert statment into an database. As long as the SQL server has been on the same machine as the application there have been acceptable performace but now are we trying to move some […]

A transport-level error has occurred when receiving results from the server. – What's the SqlException ErrorCode and Number?

We’re getting these errors in an environment where I’d rather not drop code just to determine the SqlException’s Number and ErrorCode. I’m trying to put in special exception handling for this error and don’t want to do string parsing. Does anyone know what error number this is or have a link to an extensive list […]

Trying to Insert Values into a Database from TextBoxes

I am totally stumped on this one, and I’m brand new to C# so maybe one of you fine folks can help me out. I’m trying to update a database from form fields using ADO.NET. Basically, the error I’m getting is that I am trying to insert null values into the database. The exact text […]

Web-Service: How to authenticate users with the SQL Server database table using VB

Can somebody tell me how to authenticate users with the SQL Server database table using VB as a web service. I managed to connect to the SQL server via this VB code; Public Sub ConnectToSQL() Dim con As New SqlConnection Dim cmd As New SqlCommand Try con.ConnectionString = “Data Source=(local);Initial Catalog=TestDatabase;Persist Security Info=True;User ID=sa;Password=421” con.Open() […]

ADO Exception Operand type clash

Hi I’m getting a strange error need another set of eyes I have this code: con.Open(); var cmd = new SqlCommand(“INSERT INTO [lntmuser].[attach] ([sysid],[name],[att_size],[cid],[flags],[contents]) VALUES (@sysid, @name, @att_size, @cid, @flags, @contents)”, con) { CommandType = CommandType.Text }; (Blah, Blah, ASIGN FIRST 5 VALUES, These All work) cmd.Parameters.AddWithValue(“@contents”, SqlDbType.Image).Value = aa.contents ?? (object) DBNull.Value; Where aa.contents […]

Can't find a solution to a insert query and foreign key conflict ADO.NET C#

Here’s the exception text Instrucción INSERT en conflicto con la restricción FOREIGN KEY “FK__Pedidos__idClien__74AE54BC”. El conflicto ha aparecido en la base de datos “FB4D5206F5E37B80717CE8DC9CC0F063_CTS\SISTEMA DE GESTIÓN – ESCALANDRÚN\SISTEMA DE GESTIÓN -ESCALANDRÚN\BIN\DEBUG\ESCALANDRUN.MDF”, tabla “dbo.Clientes”, column ‘idCliente’. Se terminó la instrucción. Tables that are involved and queries: Pedidos(child): idPedido (PK) (Identity), idCliente (FK), FechaPedido Clientes(parent): idCliente (PK) […]

Getting error while supplying parameters to a stored procedure

I am getting the following error while supplying parameters to a stored procedure: Procedure or function ‘ismovieexists’ expects parameter ‘@movie_name’, which was not supplied and the same error message for the procedure insert_values_in_movie_master.. public int add_movie(mymovie objmymovie) { SqlConnection cn = new SqlConnection(_connectionstring); cn.Open(); //SqlDataReader dr; SqlCommand cmd = new SqlCommand(“ismovieexists”, cn); cmd.CommandType = CommandType.StoredProcedure; […]

How to insert multiple rows into an database in C#/ADO.NET?

I’ve got a DataTable which has a number of records. I’ve tried the following code for iterating through the DataTable and inserting into the database, but I am receiving an error message saying that the parameters have not been declared: using (SqlCommand command = new SqlCommand((“My insert statement”), connection)) { SqlParameter param1 = new SqlParameter(); […]

Authentification works when browsed from Visual Studio but not with IIS

I have a ASP.NET website. It’s got a login page where I use built-in Membership class for user authentication. I’ve got a weird problem. In visual Studio when I point to my Default.aspx file and select View in browser I have no problem, I enter credentials and authenticate. But when I open the same website […]

Loading multiple large ADO.NET DataTables/DataReaders – Performance improvements

I need to load multiple sql statements from SQL Server into DataTables. Most of the statements return some 10.000 to 100.000 records and each take up to a few seconds to load. My guess is that this is simply due to the amount of data that needs to be shoved around. The statements themselves don’t […]

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