|
Mostrar Mensajes
|
Páginas: [1] 2
|
2
|
Sistemas Operativos / GNU/Linux / Visual c# en Linux
|
en: 7 Marzo 2012, 16:03 pm
|
Quien me podria decir como puedo correr una aplicacion hecha en visual studio 2008 (C#) en linux. se que se puede hacer con monodevelop pero tengo un problema al instalar este software ya q no tengo experiencia en el manejo de linux (centos) alguien que podria ser tan amable de pasarme un tutorial de instalacion de dicho programa en linux . gracias
|
|
|
3
|
Programación / .NET (C#, VB.NET, ASP) / Re: Llenar datagrid en c#
|
en: 31 Diciembre 2011, 18:07 pm
|
Hay una forma mas facil de hacer lo que quieres .
Aki Esta : supongamos que mi clase se llame alumnos y quiero mostrar los datos de los alumnos en un datagird entonces yo en mi caso haria esto :
1. ala clase la haria estatica (static) 2. este es mi metodo q me devuelve un datatable
public static datatable listado(){ datatable dt=new datatable(); sqldataadapter da;
// con es mi variable de conexion
//llamamos al metodo abrir conexion o solo abrimos la conexion con sql abrir(); da=new sqldataadapter("select * from alumno",con) da.fill(dt); //ahora cerrarmos la conexion cerrar(); return dt;
}
//============AHORA EN EL FORMULARIO DONDE STA EL GRID
creamos un void void llenardatos(){ datagridview1.datasource=akinombredelaclase.nombremetodo.listado();
}
--=========en el evento load del formulario llenardatos();
//en tu caso llamaria a tu capa.nombredeclase.metodo , //debes averle dado referencia //buenoe so es todo //ojala te sirva
|
|
|
4
|
Programación / .NET (C#, VB.NET, ASP) / Re: ¿Como enlazar Sql server con Visual Basic.net 2008?
|
en: 22 Noviembre 2011, 02:03 am
|
Oe men si quieres conectar Sql Server con Visual Net usa una cadena de conexion para asi poder modificar el contenido o registros de las tablas. Codigo de conexion: --Cabecera import system.data import system.data.sqlclient ------ public con as new sqlconnection("Server=.;DataBase=NombreBD;Integrated Security=true"); 'el . en la cadena de conexion corresponde a tu servidor con el q entras a SQL 'metodos para abrir conexion sub abrir if con.state=0 then con.open() end sub
sub cerrar if con.state=1 then con.close() end dub --ya esta ahora esos metodos de abrir y cerrar se usan cuando quieres modificar --las tablas de tu BD ya sea registrando , eliminado,Modificando , etc
AKI UN EJEMPLO UTILIZANDO UNA BD : ejercicioGO USE master GO IF(DB_ID('ejercicio')IS NOT NULL) DROP DATABASE ejercicio GO CREATE DATABASE ejercicio GO USE ejercicio GO CREATE TABLE producto ( idp CHAR(3)PRIMARY KEY, nombre VARCHAR(30)NOT NULL, procedencia VARCHAR(20)NOT NULL CHECK (procedencia IN('Nacional','Importado')), precio money, presentacion VARCHAR(15)NOT NULL CHECK(presentacion IN('Caja','Lata','Bolsa')), stock INT NOT NULL CHECK(stock >0), fvencimiento DATE) GO CREATE proc registrar( @idp CHAR(3), @nombre VARCHAR(30), @proc VARCHAR(20), @precio money, @presen VARCHAR(15), @stock INT, @fv DATE, @msj VARCHAR(60)output) AS BEGIN IF(EXISTS(SELECT * FROM producto WHERE idp =@idp )) SET @msj ='el id '+','+@idp +'Producto ya existe' ELSE BEGIN INSERT producto VALUES(@idp ,@nombre ,@proc ,@precio ,@presen ,@stock ,@fv ) SET @msj ='DATOS REGISTRADOS' END END
--ahora el code en visual Imports System.Data Imports System.Data.SqlClient Public Class Form1 Public con As New SqlConnection("Server=.;DataBase=ejercicio;Integrated Security=true") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cbxpresentacion.Items.Add("Seleccione") : cbxpresentacion.Items.Add("Caja") cbxpresentacion.Items.Add("Lata") : cbxpresentacion.Items.Add("Bolsa") rbtnacional.Checked = True cbxpresentacion.SelectedIndex = 0 'para validar meses vermes() End Sub Sub abrir() If con.State = 0 Then con.Open() End Sub Sub cerrar() If con.State = 1 Then con.Close() End Sub Private Sub btnregistrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnregistrar.Click If txtcodigo.Text <> "" And txtnombre.Text <> "" And txtprecio.Text <> "" And txtstock.Text <> "" Then If cbxpresentacion.SelectedIndex <> 0 Then Try Dim cmd As New SqlCommand Dim msje As String = "" abrir() cmd = New SqlCommand("registrar", con) cmd.CommandType = 4 With cmd.Parameters .AddWithValue("@idp", txtcodigo.Text) .AddWithValue("@nombre", txtnombre.Text) If rbtnacional.Checked = True Then .AddWithValue("@proc", "Nacional") Else .AddWithValue("@proc", "Importado") End If .AddWithValue("@precio", txtprecio.Text) .AddWithValue("@presen", cbxpresentacion.Text) .AddWithValue("@stock", txtstock.Text) .AddWithValue("@fv", datefv.Value) .Add("@msj", SqlDbType.VarChar, 60).Direction = 2 cmd.ExecuteNonQuery() msje = cmd.Parameters("@msj").Value MessageBox.Show(msje) limpiar() End With Catch ex As Exception End Try cerrar() Else MessageBox.Show("Seleccione Un Indice del Combo") End If Else MessageBox.Show("Llene Cajas") End If End Sub Sub limpiar() txtcodigo.Clear() : txtnombre.Clear() : txtprecio.Clear() txtstock.Clear() rbtnacional.Checked = True cbxpresentacion.SelectedIndex = 0 End Sub Sub vermes() ',con esto al momento de escoger el valor del datetimepicker 'el mes se suma 2 Dim mes As Integer = Now.Month datefv.MinDate = New DateTime(Now.Year, mes + 2, Now.Day) End Sub Private Sub datefv_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles datefv.ValueChanged vermes() End Sub End Class
AKI IMAGEN DE FORMULARIO http://img706.imageshack.us/img706/1684/89998267.jpg-- dame un me gusta http://www.facebook.com/pages/Programadores/217326488292716
|
|
|
7
|
Programación / PHP / servicio de correo
|
en: 13 Julio 2011, 18:17 pm
|
Bueno ante todo Hola quisiera saber si alguien posee ejemplos de como enviar mensajes de correo desde una pagina hecha en php o jsp.
Ante todo les agradezco mucho
|
|
|
10
|
Programación / Desarrollo Web / ejercico asp con conexión a sql
|
en: 18 Marzo 2011, 16:44 pm
|
_Este ejercicio consiste en registrar buscar y modificar datos que se encuentran en una base de datos
_utilizaremos Visual studio 2010 _Sql server 2008 _crearemos un nuevo sitio web aki la interfazhttp://img13.imageshack.us/i/webfya.jpg/aki el codigo de sql go use master go if(DB_ID('parcialvidarteDelgad')is not null) drop database parcialvidarteDelgad go create database parcialvidarteDelgad go use parcialvidarteDelgad go create table tipopelicula( tipo varchar(14)primary key ) go insert tipopelicula values ('DRAMA') insert tipopelicula values ('Suspenso') insert tipopelicula values ('Terror') insert tipopelicula values ('CienciaFiccion') insert tipopelicula values ('Otros') go create table pelicula( id int identity primary key, nombre varchar(30)unique, tipo varchar(14)foreign key references tipopelicula, añof date, stock int ) go create proc listartipo(@tipo varchar(30)) as begin select * from pelicula where tipo =@tipo end go create proc registrar(@n varchar(30),@tipo varchar(14),@añof date,@stock int,@msj varchar(60)output) as begin if (exists(select * from pelicula where nombre =@n )) set @msj ='Ya existe pelicula' else begin insert into pelicula values(@n ,@tipo ,@añof ,@stock ) set @msj ='OK' end end GO create proc MODIFICAR(@id int,@n varchar(30),@tipo varchar(14),@añof date,@stock int,@msj varchar(60)output) as begin if (NOT exists(select * from pelicula where id =@id )) set @msj ='no existe pelicula' else begin update pelicula set nombre =@n ,tipo =@tipo ,añof=@añof ,stock =@stock where id =@id set @msj ='OK' end end go create proc buscar(@id int) as begin select * from pelicula where id =@id end go insert into pelicula values('Odisea','DRAMA','10/10/2010',18) go
Ahora el codigo en Vb nota: activamos en la venta de propiedad ispostback=true en la barra de propiedades del combobox o cbxtipo
Imports System.Data Imports System.Data.SqlClient Partial Class pagina1 Inherits System.Web.UI.Page Private con As New SqlConnection("Server=.;DataBase=parcialvidarteDelgad;Integrated Security=true") Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click Dim cmd As New SqlCommand Dim msj As String = "" Try abrir() cmd = New SqlCommand("registrar", con) cmd.CommandType = 4 With cmd.Parameters .AddWithValue("@n", txtn.Text) .AddWithValue("@tipo", cbxtipo.SelectedValue) .AddWithValue("@añof", CDate(txtaño.Text)) .AddWithValue("@stock", CInt(txtstock.Text)) .Add("@msj", SqlDbType.VarChar, 60).Direction = 2 End With cmd.ExecuteNonQuery() msj = cmd.Parameters("@msj").Value MsgBox(msj) Catch ex As Exception MsgBox(ex.Message) End Try cerrar() limpiar() End Sub Sub limpiar() txtaño.Text = "" txtid.Text = "" txtn.Text = "" txtstock.Text = "" End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then listartipos() End If End Sub Sub listartipos() Dim dt As New DataTable Dim da As SqlDataAdapter Try abrir() da = New SqlDataAdapter("select * from tipopelicula", con) da.Fill(dt) cbxtipo.DataValueField = "tipo" cbxtipo.DataTextField = "tipo" cbxtipo.DataSource = dt cbxtipo.DataBind() Catch ex As Exception MsgBox(ex.Message) End Try cerrar() End Sub Sub abrir() If con.State = 0 Then con.Open() End Sub Sub cerrar() If con.State = 1 Then con.Close() End Sub Protected Sub cbxtipo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbxtipo.SelectedIndexChanged Dim dt As New DataTable Dim da As SqlDataAdapter Try abrir() da = New SqlDataAdapter("listartipo", con) da.SelectCommand.CommandType = 4 da.SelectCommand.Parameters.AddWithValue("@tipo", cbxtipo.SelectedValue) da.Fill(dt) GridView1.DataSource = dt GridView1.DataBind() Catch ex As Exception MsgBox(ex.Message) End Try cerrar() End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Dim dt As New DataTable Dim da As SqlDataAdapter Try abrir() da = New SqlDataAdapter("buscar", con) da.SelectCommand.CommandType = 4 da.SelectCommand.Parameters.AddWithValue("@id", txtid.Text) da.Fill(dt) txtid.Text = dt.Rows(0).Item(0).ToString txtn.Text = dt.Rows(0).Item(1).ToString cbxtipo.Text = dt.Rows(0).Item(2).ToString txtaño.Text = dt.Rows(0).Item(3).ToString txtstock.Text = dt.Rows(0).Item(4).ToString Catch ex As Exception MsgBox(ex.Message) End Try cerrar() End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cmd As New SqlCommand Dim msj As String = "" Try abrir() cmd = New SqlCommand("MODIFICAR", con) cmd.CommandType = 4 With cmd.Parameters .AddWithValue("@id", txtid.Text) .AddWithValue("@n", txtn.Text) .AddWithValue("@tipo", cbxtipo.SelectedValue) .AddWithValue("@añof", CDate(txtaño.Text)) .AddWithValue("@stock", CInt(txtstock.Text)) .Add("@msj", SqlDbType.VarChar, 60).Direction = 2 End With cmd.ExecuteNonQuery() msj = cmd.Parameters("@msj").Value MsgBox(msj) Catch ex As Exception MsgBox(ex.Message) End Try cerrar() limpiar() End Sub Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click limpiar() End Sub End Class
eso es todo espero que les haya servido
|
|
|
|
|
|
|