protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(@$ "Data Source={DataSource}; Database=advLarsAndersson;Integrated Security=True; Connect Timeout=30;Encrypt=False; TrustServerCertificate=False; ApplicationIntent=ReadWrite; MultiSubnetFailover=False; MultipleActiveResultSets = True;").UseLazyLoadingProxies(); }
public override int GetHashCode() { unchecked { var result = Integrated.GetHashCode(); result = (result * 397) ^ (Path != null ? Path.GetHashCode() : 0); result = (result * 397) ^ (Username != null ? Username.GetHashCode() : 0); result = (result * 397) ^ (Password != null ? Password.GetHashCode() : 0); result = (result * 397) ^ (ProxySettings != null ? ProxySettings.GetHashCode() : 0); return(result); } }
public void ViewAllIssuedBooks() { SqlConnection conn = new SqlConnection("Data Source =.\SQLEXPRESS; Integrated security = SSPI; database = MICS"); conn.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM IssuedBooks", conn); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; conn.Close(); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {//well this sucks optionsBuilder.UseInternalServiceProvider("Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=_2020_07_23_EFCodeFirstDatabase.VartotojuDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); }
public void SetUpTests() { var projectPath = @"C:SomeDirectory"; var project = new Project(projectPath); project.Build(); ProjectCollection.GlobalProjectCollection.UnloadProject(project); var dacPac = new DacPacUtility(); var connString = "Data Source=(localdb)\ProjectsV12;Initial Catalog=Tests;Integrated Security=True"; var dacPacPath = projectPath + "..\bin\projectName.dacpac"; dacPac.DeployDacPac(connString, dacPacPath, "Tests"); }
public static async Task MainAsync() { var optionsBuilder = new DbContextOptionsBuilder <MyDbContext>(); optionsBuilder.UseSqlServer(@$ "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={GetDbPath()}\db.mdf;Integrated Security=True"); using var context = new MyDbContext(optionsBuilder.Options); try { var futureCount = context.IntCounts .FromSqlInterpolated($@"SELECT Count(*) as [Count] FROM Profile p WHERE p.Id = {1}").FutureValue(); var students = context.Profiles .FromSqlInterpolated($@"SELECT * FROM Profile p WHERE p.Id > {1} ORDER BY Id OFFSET {0} ROWS FETCH NEXT {2} ROWS ONLY").Future(); var profiles = await students.ToListAsync(); var count = await futureCount.ValueAsync(); } catch (Exception ex) { Console.Write(ex); } try { var qry = from p in context.Profiles join pid in context.FromEnum <ProfileId>() on(int) p.Id equals pid.Value where p.Id > 0 select new ProfileView { Id = p.Id, Name = pid.Name }; var(count, items) = await qry .AsNoTracking() .GetPaged(1, p => p.Id, CancellationToken.None); Debug.Assert(count > 0); Debug.Assert(items.Length > 0); } catch (Exception ex) { Console.Write(ex); } }
public Transacciones() { this.sql = ""; this.con = new SqlConnection(); this.cmd = new SqlCommand(); this.con.ConnectionString = "Data Source=HP-PC\SQLEXPRESS; Initial Catalog=DBNotas_Bachillerato; Integrated Security=True"; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } var serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); // Migrate DbContextOptionsBuilder <UnixDbContext> optionsBuilder = new DbContextOptionsBuilder <UnixDbContext>(); optionsBuilder.UseSqlServer(@$ "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={this.DB_PATH};Integrated Security=True"); UnixDbContext unixDbContext = new UnixDbContext(optionsBuilder.Options); unixDbContext.Database.Migrate(); // Seed database var serviceProvider = serviceCollection.BuildServiceProvider(); serviceProvider.GetService <ISeeder>().Seed(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); app.UseHttpsRedirection(); app.UseStaticFiles(); if (!env.IsDevelopment()) { app.UseSpaStaticFiles(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); } }
private void Load() { DatachamcongDataContext db = new DatachamcongDataContext("Data Source=NVO1JL5GTOVLFWA\SQLEXPHLHR;Initial Catalog=HLHRDB;Integrated Security=True"); var dschamcong = db.CHAM }
private DbContextOptions <MemCheckDbContext> DbContextOptions() { var connectionString = @$ "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog={GetType().Name};Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; var result = new DbContextOptionsBuilder <MemCheckDbContext>().UseSqlServer(connectionString).Options; using (var dbContext = new MemCheckDbContext(result)) { dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); } return(result); }
public Startup(IConfiguration configuration, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { Configuration = configuration; var contentRoot = env.ContentRootPath; Cs.CsStr = @$ "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={contentRoot}\wwwroot\Diplomka.mdf;Integrated Security=True"; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); string connection = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=LojaVirtual;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; services.AddDbContext <LojaVirtualContext>(options => options.UseSqlServer(connection)); }
public void ExecutaInstrucaoNaBase(string QuerySQL) { Configuracao conf = new Configuracao(); string strConxao = conf.StrConfiguracao; "Data Source=LAPTOP-8C3VQ7PF\SQLEXPRESS;Initial Catalog=PIM_BlockChain;Integrated Security=True"; string Query = QuerySQL; SqlConnection con = new SqlConnection(strConxao); SqlCommand sqlCommand = new SqlCommand(Query, con); try { con.Open(); sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { string erro = ex.Message; erro += " !!!"; } finally { con.Close(); } }
protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@ "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"); SqlCommand cmd = new SqlCommand("select * from tbl_data where username=@username and word=@word", con); cmd.Parameters.AddWithValue("@username", TextBox1.Text); cmd.Parameters.AddWithValue("word", TextBox2.Text); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (dt.Rows.Count > 0) { Response.Redirect("Redirectform.aspx"); } else { Label1.Text = "Your username and word is incorrect"; Label1.ForeColor = System.Drawing.Color.Red; } }
public ActivitiesDbContext CreateDbContext(string[] args) { DbContextOptionsBuilder <ActivitiesDbContext> builder = new DbContextOptionsBuilder <ActivitiesDbContext>(); var context = new ActivitiesDbContext( builder .UseSqlServer("Data Source=(local)\LocalDB;Initial Catalog=DB_name;Integrated Security=True;")
public SqlConnection Baglanti() { SqlConnection baglan = new SqlConnection(Data Source = LAPTOP - AK5T9PFP \ \ SQLEXPRESS; Initial Catalog = HastaneProje; Integrated Security = True); baglan.Open(); return(baglan); }
public static async Task MainAsync() { var optionsBuilder = new DbContextOptionsBuilder <MyDbContext>(); optionsBuilder.UseSqlServer(@$ "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={GetDbPath()}\db.mdf;Integrated Security=True"); using var context = new MyDbContext(optionsBuilder.Options); try { var futureCount = context.IntCounts .FromSqlInterpolated($@"SELECT Count(*) as [Count] FROM Profile p WHERE p.Id = {1}").FutureValue(); var students = context.Profiles .FromSqlInterpolated($@"SELECT [Id] FROM Profile p WHERE p.Id > {1} ORDER BY Id OFFSET {0} ROWS FETCH NEXT {2} ROWS ONLY").Future(); var profiles = await students.ToListAsync(); var count = await futureCount.ValueAsync(); } catch (Exception ex) { Console.Write(ex); } }
// GET: Student public ActionResult Index() { String connectionString = "<Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20170222054809.mdf;Initial Catalog=aspnet-WebApplication1-20170222054809;Integrated Security=True" providerName = "System.Data.SqlClient/>"; String sql = "SELECT * FROM students"; SqlCommand cmd = new SqlCommand(sql, conn); var model = new List <Student>(); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var student = new Student(); student.FirstName = rdr["FirstName"]; student.LastName = rdr["LastName"]; student.Class = rdr["Class"]; model.Add(student); } } return(View(model)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddSwaggerGen(); // Seed database with samples services.AddTransient <ISeeder, Seeder>(); services.AddDbContext <UnixDbContext>(options => options.UseSqlServer(@$ "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={this.DB_PATH};Integrated Security=True")); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
static void Main(string[] args) { SqlConnection conn = new SqlConnection("server=.\MTCDB;Database=JobSearch;Integrated Security=true"); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT CompanyName FROM Companies"); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine("{1}", reader.GetString(0), reader.GetString(1)); } reader.Close(); conn.Close(); if (Debugger.IsAttached) { Console.ReadLine(); } }
public void Connect() { string connectionString = "Data Source=DESKTOP-4OS0TGP\SQLEXPRESS;Initial Catalog=TunaGestDB;Integrated Security=True"; SqlConnection connection; connection = new SqlConnection(connectionString); connection.Open(); }
public string obtenerTasaCambio(string pMoneda) { SqlConnection ocon = new SqlConnection("Data Source=.\;Initial Catalog=RMDB;Integrated Security=True"); return("testing"); }
public ProcedureHelper() { connectionString = Data Source = HOANGIT7; Initial Catalog = DbPratice; Integrated Security = True; }
protected void btnLogin_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=ARIF-PC\SQLEXPRESS;Initial Catalog=Giftz;Integrated Security=True"); con.Open(); string query = "sp_checkLogin"; SqlCommand cmd = new SqlCommand(query, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@user", txtLoginID.Text); cmd.Parameters.AddWithValue("@pass", txtPassword.Text); string output = cmd.ExecuteScalar().ToString(); if (output == "1") { Response.Redirect(""); } else { lbl_alert.Text = "failed"; con.Close(); } }
public static string ConexionBD() { string _out = "Conexión a la B.D. exitosa"; SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=VORTIZ\SQLSERVER2012;Initial Catalog=TEST;Integrated Security=True"; try { conn.Open(); } catch (SqlException ex) { throw ex; } return _out; }
/* باني افتراضي لاجل بناء اتصال */ public Connection() { cn = new SqlConnection(@$ "Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = {path}\coptic.mdf; Integrated Security = True; Connect Timeout = 30"); }
public Usuario() { this.Conn = new SqlConnection( "Data Server=localhost\SQLEXPRESS;Initial Catalog=tp2_net;Integrated Security=true;user=DESKTOP-F8EBEBO\tato9;password=2233;"); /* * Este connection string es para conectarse con la base de datos academia en el servidor * del departamento sistemas desde una PC de los laboratorios de sistemas, * si realiza este Laboratorio desde su PC puede probar el siguiente connection string * * "Data Source=localhost;Initial Catalog=academia;Integrated Security=true;" * * Si realiza esta práctica sobre el MS SQL SERVER 2005 Express Edition entonce debe * utilizar el siguiente connection string * * "Data Source=localhost\SQLEXPRESS;Initial Catalog=academia;Integrated Security=true;" */ this.daUsuarios = new SqlDataAdapter("select * from usuarios", this.Conn); this.daUsuarios.UpdateCommand = new SqlCommand(" UPDATE usuarios " + " SET tipo_doc = @tipo_doc, nro_doc = @nro_doc, fecha_nac = @fecha_nac, " + " apellido = @apellido, nombre = @nombre, direccion = @direccion, " + " telefono = @telefono, email = @email, celular = @celular, usuario = @usuario, " + " clave = @clave WHERE id=@id ", this.Conn); this.daUsuarios.UpdateCommand.Parameters.Add("@tipo_doc", SqlDbType.Int, 1, "tipo_doc"); this.daUsuarios.UpdateCommand.Parameters.Add("@nro_doc", SqlDbType.Int, 1, "nro_doc"); this.daUsuarios.UpdateCommand.Parameters.Add("@fecha_nac", SqlDbType.DateTime, 1, "fecha_nac"); this.daUsuarios.UpdateCommand.Parameters.Add("@apellido", SqlDbType.VarChar, 50, "apellido"); this.daUsuarios.UpdateCommand.Parameters.Add("@nombre", SqlDbType.VarChar, 50, "nombre"); this.daUsuarios.UpdateCommand.Parameters.Add("@direccion", SqlDbType.VarChar, 50, "direccion"); this.daUsuarios.UpdateCommand.Parameters.Add("@telefono", SqlDbType.VarChar, 50, "telefono"); this.daUsuarios.UpdateCommand.Parameters.Add("@email", SqlDbType.VarChar, 50, "email"); this.daUsuarios.UpdateCommand.Parameters.Add("@celular", SqlDbType.VarChar, 50, "celular"); this.daUsuarios.UpdateCommand.Parameters.Add("@usuario", SqlDbType.VarChar, 50, "usuario"); this.daUsuarios.UpdateCommand.Parameters.Add("@clave", SqlDbType.VarChar, 50, "clave"); this.daUsuarios.UpdateCommand.Parameters.Add("@id", SqlDbType.Int, 1, "id"); this.daUsuarios.InsertCommand = new SqlCommand(" INSERT INTO usuarios(tipo_doc,nro_doc,fecha_nac,apellido, " + " nombre,direccion,telefono,email,celular,usuario,clave) " + " VALUES (@tipo_doc,@nro_doc,@fecha_nac,@apellido,@nombre,@direccion, " + " @telefono,@email,@celular, @usuario, @clave )", this.Conn); this.daUsuarios.InsertCommand.Parameters.Add("@tipo_doc", SqlDbType.Int, 1, "tipo_doc"); this.daUsuarios.InsertCommand.Parameters.Add("@nro_doc", SqlDbType.Int, 1, "nro_doc"); this.daUsuarios.InsertCommand.Parameters.Add("@fecha_nac", SqlDbType.DateTime, 1, "fecha_nac"); this.daUsuarios.InsertCommand.Parameters.Add("@apellido", SqlDbType.VarChar, 50, "apellido"); this.daUsuarios.InsertCommand.Parameters.Add("@nombre", SqlDbType.VarChar, 50, "nombre"); this.daUsuarios.InsertCommand.Parameters.Add("@direccion", SqlDbType.VarChar, 50, "direccion"); this.daUsuarios.InsertCommand.Parameters.Add("@telefono", SqlDbType.VarChar, 50, "telefono"); this.daUsuarios.InsertCommand.Parameters.Add("@email", SqlDbType.VarChar, 50, "email"); this.daUsuarios.InsertCommand.Parameters.Add("@celular", SqlDbType.VarChar, 50, "celular"); this.daUsuarios.InsertCommand.Parameters.Add("@usuario", SqlDbType.VarChar, 50, "usuario"); this.daUsuarios.InsertCommand.Parameters.Add("@clave", SqlDbType.VarChar, 50, "clave"); this.daUsuarios.DeleteCommand = new SqlCommand(" DELETE FROM usuarios WHERE id=@id ", this.Conn); this.daUsuarios.DeleteCommand.Parameters.Add("@id", SqlDbType.Int, 1, "id"); }
public static DbContextOptions <MemCheckDbContext> GetEmptyTestDB([CallerFilePath] string callerFilePath = "") { var name = Path.GetFileNameWithoutExtension(callerFilePath); var connectionString = @$ "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog={name};Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; var result = new DbContextOptionsBuilder <MemCheckDbContext>().UseSqlServer(connectionString).Options; using (var dbContext = new MemCheckDbContext(result)) { dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); } return(result); }
private void button1_Click_1(object sender, EventArgs e) { /***************************************************************/ /*connection string */ DataContext A = new DataContext("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\maya\MAYA_STOCK\My_DB\STOCK_DB.mdf;Integrated Security=True"); var class1s = A.GetTable <Class1>(); /****************************************************/ var mdata = from data in class1s where data.USER_ID == 1 select data; if (mdata.Any()) { bool a = mdata.ToList()[0].password == "pass"; } MessageBox.Show("abu rafeeq kiss my ass"); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseLazyLoadingProxies(); optionsBuilder.UseSqlServer( @$ "Data Source=localhost\SQLEXPRESS;DataBase=VendingMachineDB;Integrated Security=True;Connect Timeout=30;AttachDbFilename={Startup.MDF_Directory}"); }