本文整理汇总了C#中SQL.Close方法的典型用法代码示例。如果您正苦于以下问题:C# SQL.Close方法的具体用法?C# SQL.Close怎么用?C# SQL.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnEmpresas_Click
protected void btnEmpresas_Click(object sender, EventArgs e)
{
entidadRFV.Enabled = false;
//entidadRFV.DataBind();
entidadRFV.EnableClientScript = false;
entidadRFV.Validate();
Page.Validate();
if (Page.IsValid && string.IsNullOrEmpty(Request.QueryString["Email"]))
{
//Guardar_Click(sender, e);
Session["Email"] = CorreoElectronico.Text;
var role = roles.Where(x => x.Nombre == roleDDL.SelectedValue).First();
using (var conn = new SQL().GetLocalConnection())
{
using (SqlCommand command = new SqlCommand())
{
command.Connection = conn;
command.CommandType = CommandType.Text;
//if (!string.IsNullOrWhiteSpace(Request.QueryString["Email"]))
//{
// command.CommandText = @"DELETE FROM Usuarios WHERE CorreoElectronico = @CorreoElectronico;";
//}
command.CommandText += @"INSERT INTO Usuarios VALUES (@NombreUsuario, @Inicial, @ApellidoPaterno, @ApellidoMaterno,
@CorreoElectronico, @ConfirmarCorreoElectronico, @Contrasena, @ConfirmarContrasena, @PreguntaSeguridad,
@RespuestaSeguridad, @Telefono, @UsuarioInterno, @EmpresaID, @Rol);";
command.Parameters.AddWithValue("@NombreUsuario", NombreUsuario.Text.ToUpper());
command.Parameters.AddWithValue("@Rol", role.ID);
command.Parameters.AddWithValue("@Inicial", Inicial.Text.ToUpper());
command.Parameters.AddWithValue("@ApellidoPaterno", ApellidoPaterno.Text.ToUpper());
command.Parameters.AddWithValue("@ApellidoMaterno", ApellidoMaterno.Text.ToUpper()); ;
command.Parameters.AddWithValue("@CorreoElectronico", CorreoElectronico.Text.ToLower());
command.Parameters.AddWithValue("@ConfirmarCorreoElectronico", ConfirmarCorreoElectronico.Text.ToLower());
command.Parameters.AddWithValue("@Contrasena", Contrasena.Value);
command.Parameters.AddWithValue("@ConfirmarContrasena", ConfirmarContrasena.Value);
command.Parameters.AddWithValue("@PreguntaSeguridad", PreguntaSeguridad.SelectedValue.ToString());
command.Parameters.AddWithValue("@RespuestaSeguridad", RespuestaSeguridad.Text.ToUpper());
command.Parameters.AddWithValue("@Telefono", Telefono.Text);
command.Parameters.AddWithValue("@UsuarioInterno", false);
command.Parameters.AddWithValue("@EmpresaID", string.Empty);
try
{
conn.Open();
//int recordsAffected = command.ExecuteNonQuery();
command.ExecuteNonQuery();
//if (recordsAffected == 1)
//{
//Cancelar_Click(sender, e);
//}
Session["shoulLogOut"] = false;
#region Create user document directories
Directory.CreateDirectory(Server.MapPath(string.Format("{0}/{1}",
new DocumentoRequerido().DocumentosInicialesSavePath, CorreoElectronico.Text)));
if (role.ID ==(int)Role.TipoRoles.Inspector || role.ID ==(int)Role.TipoRoles.SuperInspector)
{
Directory.CreateDirectory(Server.MapPath(string.Format("{0}/{1}",
new DocumentoRequerido().DocumentosInspeccionesSavePath, CorreoElectronico.Text)));
}
Directory.CreateDirectory(Server.MapPath(string.Format("{0}/{1}",
new DocumentoRequerido().DocumentosPrimerasSavePath, CorreoElectronico.Text)));
Directory.CreateDirectory(Server.MapPath(string.Format("{0}/{1}",
new DocumentoRequerido().DocumentosSegundasSavePath, CorreoElectronico.Text)));
#endregion
Response.Redirect("MantEmpresas.aspx?CorreoElectronico=" + CorreoElectronico.Text.ToLower());
}
catch (SqlException)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "sqlerr()", true);
}
finally
{
conn.Close();
}
}
}
}
//.........这里部分代码省略.........
示例2: itemSelected
protected void itemSelected(object sender, EventArgs e)
{
string connectionString = null;
SqlConnection conn;
SqlCommand command; string sql = null;
SqlDataReader dataReader;
//connectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=DEDT;User ID=excdem;Password=excdem";
if (Inspector.SelectedIndex > 0 || Inspector.Items.Count < 2)
{
sql = string.Format(@"SELECT NumeroControl AS CN,
(NombreEmpresa) AS NE, TipoAviso AS Ext, (RepresentanteAutorizado) AS RA, (CONVERT(VARCHAR(10), FechaComienzo, 101)) AS FC,
(CONVERT(VARCHAR(10), FechaExpiracion, 101)) AS FE, (TelOficina) AS Tel,
(CorreoElectronico) AS CE FROM Inspecciones where NombreInspector = '{0}'", Inspector.SelectedValue);
}
else
{
sql = @"SELECT NumeroControl AS CN,
(NombreEmpresa) AS NE, TipoAviso AS Ext, (RepresentanteAutorizado) AS RA, (CONVERT(VARCHAR(10), FechaComienzo, 101)) AS FC,
(CONVERT(VARCHAR(10), FechaExpiracion, 101)) AS FE, (TelOficina) AS Tel,
(CorreoElectronico) AS CE FROM Inspecciones";
}
//conn = new SqlConnection(connectionString);
conn = new SQL().GetLocalConnection();
try
{
conn.Open();
command = new SqlCommand(sql, conn);
DataTable dt = new DataTable();
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(dt);
}
//dataReader = command.ExecuteReader();
//while (dataReader.Read())
//{
// // MessageBox.Show(dataReader.GetValue(0) + " - " + dataReader.GetValue(1) + " - " + dataReader.GetValue(2));
// //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + dataReader.GetString(0) + " - " + dataReader.GetString(1), true);
// //Console.WriteLine("{0} {1} {2}", dataReader.GetString(0), dataReader.GetString(1));
//}
inspeccionesPendGV.DataSourceID = string.Empty;
inspeccionesPendGV.DataSource = dt;
inspeccionesPendGV.DataBind();
//dataReader.Close();
command.Dispose(); conn.Close();
}
catch (Exception ex)
{
// MessageBox.Show("Can not open connection ! ");
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('No se puede hacer connección con la Base de Datos.' " + ex, true);
}
}
示例3: itemSelected
protected void itemSelected(object sender, EventArgs e)
{
string connectionString = null; SqlConnection conn;
SqlCommand cmd; string sql = null;
SqlDataReader dr;
//connectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=DEDT;User ID=excdem;Password=excdem";
sql = string.Format("SELECT * From Inspectores where NombreInspector = '{0}'", ddlInspector.SelectedValue);
conn = new SQL().GetLocalConnection();
try
{
conn.Open();
cmd = new SqlCommand(sql, conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
PlacaInspector.Text = dr.GetString(0);
}
dr.Close(); cmd.Dispose(); conn.Close();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('No se puede hacer connección con la Base de Datos.'); " + ex, true);
}
}