This code down here has errors when I run it in visual studio 2022. Kindly help out. I am quite new to MVC architecture
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; // Required for using Dataset , Datatable and Sql
using System.Data.SqlClient; // Required for Using Sql
using System.Configuration; // for Using Connection From Web.config
using BussinessObject; // for acessing bussiness object class
namespace DataAccess
{
public class UserDA
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Myconstr"].ToString());
public int AddUserDetails(UserBO ObjBO) // passing Bussiness object Here
{
try
{
/* Because We will put all out values from our (UserRegistration.aspx) To in Bussiness object and then Pass it to Bussiness logic and then to DataAcess this way the flow carry on*/
SqlCommand cmd = new SqlCommand("sprocUserinfoInsertUpdateSingleItem", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", ObjBO.Name);
cmd.Parameters.AddWithValue("@Address", ObjBO.address);
cmd.Parameters.AddWithValue("@EmailID", ObjBO.EmailID);
cmd.Parameters.AddWithValue("@Mobilenumber", ObjBO.Mobilenumber);
con.Open();
int Result = cmd.ExecuteNonQuery();
cmd.Dispose();
return Result;
}
catch
{
throw;
}
}
}
}
Cymon MaxwellPosted Aug 4, 2023, 10:45 AM
The two responses seem not to work. I am getting the following errors:
Severity Code Description Project File Line Suppression State
Error CS1069 The type name 'ConnectionStringSettings' could not be found in the namespace 'System.Configuration'. This type has been forwarded to assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. DataAccessLayer C:\Users\ICT\source\repos\DataAccessLayer\UserDA.cs 13 Active
Severity Code Description Project File Line Suppression State
Error CS1069 The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly. DataAccessLayer C:\Users\ICT\source\repos\DataAccessLayer\UserDA.cs 14 Active
Severity Code Description Project File Line Suppression State
Error CS1061 'object' does not contain a definition for 'ConnectionStrings' and no accessible extension method 'ConnectionStrings' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) DataAccessLayer C:\Users\ICT\source\repos\DataAccessLayer\UserDA.cs 13 Active
Severity Code Description Project File Line Suppression State
Error CS1069 The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly. DataAccessLayer C:\Users\ICT\source\repos\DataAccessLayer\UserDA.cs 14 Active
Severity Code Description Project File Line Suppression State
Error CS1069 The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly. DataAccessLayer C:\Users\ICT\source\repos\DataAccessLayer\UserDA.cs 30 Active
Severity Code Description Project File Line Suppression State
Warning MSB3290 Failed to create the wrapper assembly for type library "{bee4bfec-6683-3e67-9167-3c0cbc68f40a}". Type library 'System' was exported from a CLR assembly and cannot be re-imported as a CLR assembly. DataAccessLayer C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 2977
Tahir AnsariPosted Aug 4, 2023, 6:18 AM
Cr BhargaviPosted Aug 4, 2023, 1:43 AM
Please try the below code: