C# Datenbank-Programmierung



Similar documents
AD A O.N. ET E Access Data Object

Form Tasarımı - 5. Veri Tabanı Veri tabanı ismi; m Tablo ismi; mt

1. La classe Connexion class Connexion {

1. Create SQL Database in Visual Studio

.OR.AT.ATTORNEY.AUCTION.BARGAINS.BAYERN.BERLIN.BLACKFRIDAY.BOUTIQUE.BRUSSELS.BUILDERS

ASP and ADO (assumes knowledge of ADO)

ADOBE READER AND ACROBAT

Access Data Object (cont.)

Using IRDB in a Dot Net Project

How To Create A Database In Araba

A Tutorial on SQL Server CMPT 354 Fall 2007

Conexión SQL Server C#

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

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

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

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

BACKING UP A DATABASE

Crystal Reports for Visual Studio.NET

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

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Bertrand Meyer. C#: Persistence

Log/Process/Hashing. Details. Activities. Processes

Implementing Specialized Data Capture Applications with InVision Development Tools (Part 2)

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

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

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

Using SQL-server as database engine

ASP.NET Programming with C# and SQL Server

How To Design An Eprescription System

Application of Data-mining Technique and Intelligent System on Demography Analysis in Nigeria

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

Creating a New Database and a Table Owner in SQL Server 2005 for exchange@pam

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

Integrating SAS and Microsoft.NET for Data Analysis

VB.NET - DATABASE ACCESS

CRM Setup Factory Installer V 3.0 Developers Guide

MS Enterprise Library 5.0 (Logging Application Block)

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

Security Awareness For Website Administrators. State of Illinois Central Management Services Security and Compliance Solutions

Ambientes de Desenvolvimento Avançados

One method for batch DHI data import into SQL-Server. A batch data import technique for DateSet based on.net Liang Shi and Wenxing Bao

GoDaddy (CentriqHosting): Data driven Web Application Deployment

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

DB Administration COMOS. Platform DB Administration. Trademarks 1. Prerequisites. MS SQL Server 2005/ Oracle. Operating Manual 09/2011

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

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

How to schedule SQL Maintenance Plan

IAC-BOX Network Integration. IAC-BOX Network Integration IACBOX.COM. Version English

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

The MAC address, short for Media Access Control address, is a number in hexadecimal format that uniquely identifies every machine on a network.

Crystal Reports. For Visual Studio.NET. Reporting Off ADO.NET Datasets

Managing MSDE with TOAD

How to setup Outlook and Outlook Web Access (OWA) to give a send receipt and a read receipt (Options)

How To Develop A Mobile Application On Sybase Unwired Platform

ZHAW Wireless LAN Operating system: Windows 7

WPF Viewer for Reporting Services 2008/2012 Getting Started

CCProxy. Server Installation

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

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

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

general VoIP-settings

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Deleting A Record Updating the Database Binding Data Tables to Controls Binding the Data Table to the Data Grid View...

A Static Analysis Framework for Database Applications

How To Create A Replica In A Database On A Microsoft Powerbook (Ahem) On A Linux Server (A.K.A.A)

Interaction Tracker Interaction Segments

Connecting to SQL server

NAS 206 Using NAS with Windows Active Directory

<option> eggs </option> <option> cheese </option> </select> </p> </form>

**Web mail users: Web mail provides you with the ability to access your via a browser using a "Hotmail-like" or "Outlook 2003 like" interface.

Microsoft SQLServer Restore / Redirected Restore Procedure

ADO.NET Using C# Student Guide Revision 4.0. Object Innovations Courses 4120 and 4121

GENERATING SQL SCRIPTS FOR STORED PROCEDURES, FUNCTIONS, VIEWS & TRIGGERS

Restoring Files. Table of Content. No-Backup. Official website: Restoring Files

Clock Link Installation Guide. Detailed brief on installing Clock Link

CHAPTER 12: DOCUMENT LOGGING

Connect to an Oracle Database from within Visual Basic 6 (Part 1)

Configuring Your Firewall for Client Access in Professional Edition

TSX ETZ Configuration of your computer for TSX ETZ direct connection by serial link. Eng V1.0

Exam Ref : Developing Windows Azure and Web Services. William Ryan Wouter de Kort Shane Milton

Helwan University & UNINETTUNO

SQL Server 2008 R2 Express Edition Installation Guide

Sharing the Argos database. Sharing the same database between several Argos users

TimePunch SQL Server Database Guide

Appendix L: Running Hazus-MH with SQL Server 2005

Video Administration Backup and Restore Procedures

SELF SERVICE RESET PASSWORD MANAGEMENT BACKUP GUIDE

ASNA DataGate Studio Working with Connections

Database Programming with C# CARSTEN THOMSEN

Changing the Display Frequency During Scanning Within an ImageControls 3 Application

Create Reports Utilizing SQL Server Reporting Services and PI OLEDB. Tutorial

WESTERNACHER OUTLOOK -MANAGER OPERATING MANUAL

CardSwipe Integration

Accessing a Microsoft SQL Server Database from SAS on Microsoft Windows

How To Download The Database Programmierung With Msql And Visual Basic.Net (For Free) For Free On Pc Or Macbook 2.1 (For Pc Or Microsoft Csharp) For A.Net

Transcription:

C# Datenbank-Programmierung Usings... 2 Verbindung herstellen SQL und Acces... 2 Verbindung schliessen SQL und Acces... 3 File open Dialog... 3 Lehar einfügen... 3 Lehar löschen... 4 Radio Button SQL & Access... 4 Anzeigen (alle Komponisten auflisten)... 4 Version 2 Seite 1 von 5 11.06.2008

Usings using System.Data; using System.Data.; using System.Data.SqlClient; using System.Data.OleDb; public class Form1 : System.Windows.Forms.Form private OleDbConnection cnn_oledb; ; public Form1() InitializeComponent(); cnn_oledb= new OleDbConnection(); Verbindung herstellen SQL und Acces private void OnConnect_Click(object sender, System.EventArgs e) cnn_oledb.close(); String stemp=""; if (this.rdbtnaccess.checked == true) cnn_oledb.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;"; cnn_oledb.connectionstring += "Data Source=" + txtaccesspfad.text; cnn_oledb.connectionstring += ";User ID=" + txtusername.text; //BenutzerName cnn_oledb.connectionstring += ";PASSWORD=" + txtpasswort.text; //BenutzerPasswort cnn_oledb.connectionstring += ";Jet OLEDB:Database Password=bbzs"; //DatenbankPasswort //cnn_access.connectionstring += ";Jet OLEDB:System Database="; //eigenes Benutzerdef-File stemp = "Access über OLEDB"; else if(this.rdbtnsqlserver.checked == true) cnn_oledb.connectionstring = "Provider=SQLOLEDB"; //SQL-Server über OLEDB cnn_oledb.connectionstring += ";Data Source=" + txtsqlipadresse.text; //Name oder IP des Servers cnn_oledb.connectionstring += ";User ID=" + txtusername.text; //BenutzerName cnn_oledb.connectionstring += ";PASSWORD=" + txtpasswort.text; //BenutzerPasswort cnn_oledb.connectionstring += ";Initial Catalog=" +txtsqldatenbank.text; //Datenbank Version 2 Seite 2 von 5 11.06.2008

stemp = "SQL-Server über OLEDB"; cnn_oledb.open(); lblverbindungsstatus.text = "Verbindung zu " + stemp + " geöffnet"; lblverbindungsstatus.forecolor = System.Drawing.Color.Green; Verbindung schliessen SQL und Acces private void OnDisconnect_Click(object sender, System.EventArgs e) cnn_oledb.close(); lblverbindungsstatus.text = "Verbindung getrennt"; lblverbindungsstatus.forecolor = System.Drawing.Color.Red; File open Dialog private void btnaccessfile_click(object sender, System.EventArgs e) this.openfiledialog1.showdialog(this); this.txtaccesspfad.text = openfiledialog1.filename; Lehar einfügen private void btnlehareinfuegen_click(object sender, System.EventArgs e) cmd.commandtext = "insert into Komponisten values (11, 'Lehar','Franz', 1870, 1948)"; cmd.executenonquery(); Version 2 Seite 3 von 5 11.06.2008

Lehar löschen private void btnleharloeschen_click(object sender, System.EventArgs e) cmd.commandtext = "delete from Komponisten where Name = 'Lehar'"; cmd.executenonquery(); Radio Button SQL & Access private void OnVerbindungChanged(object sender, System.EventArgs e) if (this.rdbtnaccess.checked == true) this.panelaccess.visible = true; this.panelsqlserver.visible = false; this.txtusername.text = "Admin"; else if(this.rdbtnsqlserver.checked == true) this.panelsqlserver.visible = true; this.panelaccess.visible = false; this.txtusername.text = "inf"; Anzeigen (alle Komponisten auflisten) private void btnallekomponisten_click(object sender, System.EventArgs e) cmd.commandtext = "Select * From Komponisten"; OleDbDataReader myreader = cmd.executereader(); listboxanswer.items.clear(); while(myreader.read()) listboxanswer.items.add(myreader.getvalue(0).tostring() + " " + myreader.getstring(1) + " " + myreader.getstring(2) ); myreader.close(); Version 2 Seite 4 von 5 11.06.2008

Übertragen SqlConnection consql = new SqlConnection(); consql.connectionstring = "Server="+txtSQLServer.Text; consql.connectionstring += ";uid="+txtsqlbenutzer.text; consql.connectionstring += ";pwd="+txtsqlpasswort.text; consql.connectionstring += ";database="+txtsqldatenbank.text; consql.open(); OleDbConnection conacc = new OleDbConnection(); conacc.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;"; conacc.connectionstring += "Data Source=" + txtaccesspfad.text; conacc.connectionstring += ";User ID=" + txtaccessbenutzer.text; //BenutzerName conacc.connectionstring += ";PASSWORD=" + txtaccesspasswort.text; OleDbCommand cmdacc = new OleDbCommand("select * from " + txttable.text + " where klasse='"+txtexklasse.text+"'", conacc); conacc.open(); OleDbDataReader myreader = cmdacc.executereader(); SqlCommand cmdsql = new SqlCommand(); cmdsql.connection = consql; while(myreader.read()) cmdsql.commandtext = "insert into "+txttable.text+"(name,vorname,klasse) values('" + myreader.getstring(0) + "','" + myreader.getstring(1) + "','" + myreader.getstring(2) + "')"; cmdsql.executenonquery(); myreader.close(); consql.close(); catch(system.data.oledb.oledbexception ex) MessageBox.Show(ex.Message); catch(invalidoperationexception e2) MessageBox.Show(e2.Message); Version 2 Seite 5 von 5 11.06.2008