Conexión SQL Server C#



Similar documents
How To Create A Database In Araba

I A Form és a párbeszédablakok I.1. MessageBox osztály MessageBox.Show(szöveg[,cím[,gombok[,ikon[,defaultbutton]]]]);

Aucune validation n a été faite sur l exemple.

PROCEDURE INSERTION(NUM IN EMPLOYES.NUMEMP%TYPE, NOM VARCHAR2, PRENOM IN VARCHAR2, PPHOTO IN BLOB, SALAIRE IN NUMBER);

ADOBE READER AND ACROBAT

A Step by Step Guide for Building an Ozeki VoIP SIP Softphone

5 Airport. Chapter 5: Airport 49. Right-click on Data Connections, then select Add Connection.

1. La classe Connexion class Connexion {

1.Tüm Kayıtları Getirme - Arama Yapma

How To Develop A Mobile Application On Sybase Unwired Platform

如 何 在 C#.2005 中 使 用 ICPDAS I/O Card 的 DLL 檔 案

VB.NET - DATABASE ACCESS

Database Communica/on in Visual Studio/C# using Web Services. Hans- Pe=er Halvorsen, M.Sc.

ASP.NET(C#) ile Kayıt Listeleme, Silme ve Düzenleme İşlemi

Tutorial 1: M/M/n Service System Simulation Tutorial 2: M/M/n Simulation using Excel input file Tutorial 3: A Production/Inventory System Simulation

Aplicação ASP.NET MVC 4 Usando Banco de Dados

Tutorial: Windows Mobile Application Development. Sybase Unwired Platform 2.1 ESD #2

Introduction to Visual Studio and C#

Chapter 14 WCF Client WPF Implementation. Screen Layout

How To Design An Eprescription System

SQL injection attacks SQL injection user input SQL injection SQL Command parameters Database account. SQL injection attacks Data Code

A PROJECT REPORT ON. SkyDrive. Submitted for the partial fulfillment of the requirement for the Award of the degree of MASTER OF COMPUTER APPLICATION

ASP and ADO (assumes knowledge of ADO)

Systems Programming & Scripting

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

Real-World ASP.NET: Building a Content Management System

MyChartWebPart.cs. // For SortList using System.Collections.Generic; using System.Collections; // For DataTable using System.Data;

listboxgaatmee.dragdrop += new DragEventHandler(listBox_DragDrop); ListBox from = (ListBox)e.Data.GetData(typeof(ListBox));

Capturx for SharePoint 2.0: Notification Workflows

{ oledbdataadapter1.updatecommand.commandtext = "update personel set ad='" + textbox2.text + "' where id=" + textbox1.text; oledbconnection1.

USER GUIDE Appointment Manager

ASP.NET Programming with C# and SQL Server

C# Datenbank-Programmierung

Interaction Tracker Interaction Segments

Hi, processing. Code of the vb.net version. Imports System.Data Imports System.Data.SqlClient

FANESE Faculdade de Administração e Negócios de Sergipe. Tópicos Avançados em Desenvolvimento WEB. Prof.: Fabio Coriolano.

Access Data Object (cont.)

Using ilove SharePoint Web Services Workflow Action

Alsafeer software for teaching computer literacy

ASP.NET Dynamic Data

Using IRDB in a Dot Net Project

DEVELOPING A PHD MONITORING TOOL USING ASP.NET AND SQL SERVER. A Report Submitted In Partial Fulfillment Of Course BITS C331 Computer Oriented Project

Mobile Application Development Using.NET

Creating the Product Catalog Part I (continued)

İNTERNET TABANLI PROGRAMLAMA- 13.ders GRIDVIEW, DETAILSVIEW, ACCESSDATASOURCE NESNELERİ İLE BİLGİ GÖRÜNTÜLEME

Windows Mobile Power Management

Integration guide Rabo OmniKassa

AD A O.N. ET E Access Data Object

TP : Système de messagerie - Fichiers properties - PrepareStatement

טכנולוגיית WPF מספקת למפתחים מודל תכנות מאוחד לחוויית בניית יישומיי. ניהול התצוגה מתבצע בשפת הסימון Extensible Application Markup ) XAML

To be able to use web parts to create a portal-style web application

Database Communica/on in Visual Studio/C# using ASP.NET Web Forms. Hans- PeBer Halvorsen, M.Sc.

Secure Routing and Identifying Hacking In P2p System

How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET

BACKING UP A DATABASE

Beginning MYSQL 5.0. With. Visual Studio.NET 2005

CHAPTER 10: WEB SERVICES

Web Services API Developer Guide

A Tutorial on SQL Server CMPT 354 Fall 2007

wpf5concat Start Microsoft Visual Studio. File New Project WPF Application, Name= wpf5concat OK.

APPLICATION NOTE. Atmel AVR10006: XDK User Guide. Atmel Microcontrollers. Features. Description

Software Engineering 1 EEL5881 Spring Homework - 2

Getting Started with Telerik Data Access. Contents

SharePoint Integration

Implementing a WCF Service in the Real World

MS Enterprise Library 5.0 (Logging Application Block)

WINDOWS FORMS DEVELOPMENT

Mastering Visual Basic.NET Database Programming Evangelos Petroutsos; Asli Bilgin

Chapter 9 Delegates and Events

v1.1.0 SimpleSQL SQLite manager for Unity3D echo17.com

Crystal Reports. For Visual Studio.NET. Designing and Viewing a Report in a Windows Application

Ambientes de Desenvolvimento Avançados

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring

Log/Process/Hashing. Details. Activities. Processes

Sage HRMS 2015 Sage Employee Self Service Advanced Customization. February 2015

How to create a SMTP plugin for ArGoSoft Mail Server,.NET edition (AMS.NET edition) using Visual Studio 2005

Introduction to C# Programming and the.net Framework: (PDF)

SQL Server Database Web Applications

MAP524/DPS924 MOBILE APP DEVELOPMENT (ANDROID) MIDTERM TEST OCTOBER 2013 STUDENT NAME STUDENT NUMBER

Mapping Specification for DWG/DXF (MSD) C#.NET Code Samples

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from

EMC Documentum Application Connectors Software Development Kit

WINDOWS PRESENTATION FOUNDATION LEKTION 3

Einführung in die Windows Store App Entwicklung mit C# und XAML. Modul 2 Datenbindung und Zugriff auf das lokale Dateisystem

Using C# for Graphics and GUIs Handout #2

Converting Relational Database Into Xml Document

ASP.NET Using C# (VS2012)

Implementation of the AutoComplete Feature of the Textbox Based on Ajax and Web Service

CRM Setup Factory Installer V 3.0 Developers Guide

Overview of Web Services API

Curso SQL Server 2008 for Developers

Using scanners with Axapta Document Management

Transcription:

Conexión SQL Server C# Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace EXAMPLE public partial class Form1 : Form Persona per = new Persona(); public Form1() InitializeComponent(); private void button1_click(object sender, EventArgs e) per.obtenerdatos(convert.toint32(textbox4.text)); textbox1.text = Convert.ToString(per.getId()); textbox2.text = per.getnombre(); textbox3.text = per.getdireccion(); private void button2_click(object sender, EventArgs e) textbox1.clear(); textbox2.clear(); textbox3.clear(); textbox4.clear(); 1 C O N E X I Ó N S Q L S E R V E R C#

private void button4_click(object sender, EventArgs e) MessageBox.Show("ID ELIMINADO","ALERTA"); per.borradatos(convert.toint32(textbox1.text)); private void button3_click(object sender, EventArgs e) MessageBox.Show("ID AGREGADO","ALERTA"); per.agregadatos(convert.toint32(textbox1.text),textbox2.text,textbox3.text); private void button5_click(object sender, EventArgs e) MessageBox.Show("ID MODIFICADO", "ALERTA"); per.moddatos(convert.toint32(textbox1.text), textbox2.text, textbox3.text); Persona.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; namespace EXAMPLE class Persona DataTable datos; private string nombre, direccion; private int id,c=0; private Conexion con = new Conexion(); public void setnombre(string nom) 2 C O N E X I Ó N S Q L S E R V E R C#

nombre = nom; public string getnombre() return nombre; public void setid(int id) this.id = id; public int getid() return id; public void setdireccion(string direccion) this.direccion = direccion; public string getdireccion() return direccion; public void obtenerdatos(int ide) datos = Conexion.getDatos(ide); id = (int)datos.rows[c]["id"]; nombre = (string)datos.rows[c]["nombre"]; direccion = (string)datos.rows[c]["direccion"]; c++; MessageBox.Show("ERROR:" + ex.message); 3 C O N E X I Ó N S Q L S E R V E R C#

public void borradatos(int ide) datos = Conexion.getBorra(ide); public void agregadatos(int ide,string direccion,string nombre) datos = Conexion.getAgrega(ide, nombre, direccion); public void moddatos(int ide, string direccion, string nombre) datos = Conexion.getModi(ide, nombre, direccion); Conexion.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; namespace EXAMPLE class Conexion private static SqlConnection conexion; private static SqlDataAdapter dataadapter; private static DataSet dataset = new DataSet(); private string strconexion; public Conexion() strconexion = "Data Source=UBAM-3E94707E14;" + "Initial Catalog=Persona;" + "Integrated Security=True"; 4 C O N E X I Ó N S Q L S E R V E R C#

conexion = new SqlConnection(strConexion); public static DataTable getdatos(int id) string consulta; consulta = "Select * from datos where id=" + id + ";"; dataadapter = new SqlDataAdapter(consulta,conexion); conexion.open(); dataadapter.fill(dataset, "Persona"); MessageBox.Show("Error: " + ex.message); conexion.close(); return dataset.tables["persona"]; public static DataTable getborra(int id) string consulta; consulta = "Delete from datos where id=" + id + ";"; dataadapter = new SqlDataAdapter(consulta, conexion); conexion.open(); dataadapter.fill(dataset, "Persona"); MessageBox.Show("Error: " + ex.message); conexion.close(); return dataset.tables["persona"]; 5 C O N E X I Ó N S Q L S E R V E R C#

public static DataTable getagrega(int id,string direccion,string nombre) string consulta; consulta = "Insert into datos values(" + id + "," + "'" + nombre + "'" + "," + "'" + direccion + "'" + ")" + ";"; dataadapter = new SqlDataAdapter(consulta, conexion); conexion.open(); dataadapter.fill(dataset, "Persona"); MessageBox.Show("Error: " + ex.message); conexion.close(); return dataset.tables["persona"]; public static DataTable getmodi(int id, string direccion, string nombre) string consulta; consulta = "Update datos set nombre=" + "'" + nombre + "'" + ",direccion=" + "'" + direccion + "'" + "where id=" + id + ";"; dataadapter = new SqlDataAdapter(consulta, conexion); conexion.open(); dataadapter.fill(dataset, "Persona"); MessageBox.Show("Error: " + ex.message); conexion.close(); return dataset.tables["persona"]; 6 C O N E X I Ó N S Q L S E R V E R C#

Salida En Pantalla 7 C O N E X I Ó N S Q L S E R V E R C#

8 C O N E X I Ó N S Q L S E R V E R C#