Tag: ado.net

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 […]

Using ADO .NET convert datatime from sql Server to DateTime in VB .NET

I have created a Web Service in Visual Studio 2005, using VB .NET language. This Web Service interacts with a database on Sql Server through ADO .NET. Using ADO .NET I get one table with this code conn = New SqlConnection(Utilities.ConnectionString) sqlcmd = New SqlClient.SqlCommand() sqlcmd.Connection = conn sqlcmd.CommandType = CommandType.Text sqlcmd.CommandText = “select * […]

Write Null in Database if the TextBoxes are Empty

All I want to do is to insert Null with the database when the textbox is empty. –ACCOUNT AS BEGIN — SET NOCOUNT ON added to prevent extra result sets from — interfering with SELECT statements. SET NOCOUNT ON; SET IDENTITY_INSERT account ON INSERT INTO dbo.account ( AccntID , managedby , AccountHolder , Description , […]

Error converting data type nvarchar to numeric

I used the following statement for a parameter. comm.Parameters.Add(“@name”, SqlDbType.NVarChar, 50).Value = txtname.Text; Name is a SQL Server nvarchar column but I get this error: Error converting data type nvarchar to numeric. My sql: SqlCommand comm = conn.CreateCommand(); comm.CommandText = “execute addName @name”; comm.Parameters.Add(“@name”, SqlDbType.NVarChar, 50).Value = txtname.Text; conn.Open(); comm.ExecuteNonQuery(); conn.Close(); Can help my to […]

ConnectionString for SQL Server

I have xampp installed in my computer. I am trying to access data with ADO.Net. The connection string I am using is given below: string connectionString = “Server = localhost; Database = magento; User Id = magento; Password = abcd;”; SqlConnection con = new SqlConnection(connectionString); string cmdString = “SELECT date_added,title,description,url FROM adminnotification_inbox”; SqlDataAdapter da = […]

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