Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace Baze_LV6_predlozak
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void btnSve_Click(object sender, EventArgs e)
- {
- // OVDJE SLIJEDI PRIMJER IZ PREDLOŠKA:
- SqlConnection conn = new SqlConnection("Data Source=192.168.26.14;Initial Catalog=stuslu;User ID=stuslu;Password=stuslu");
- conn.Open();
- string statement = "SELECT * FROM student";
- SqlDataAdapter dataAdapter = new SqlDataAdapter(statement, conn);
- DataTable dt = new DataTable();
- dataAdapter.Fill(dt);
- dgvPodaci.DataSource = dt;
- conn.Close();
- }
- private void btnTrazi_Click(object sender, EventArgs e)
- {
- // OVDJE PISATI KOD 1. ZADATKA IZ PREDLOŠKA:
- char spol;
- if (rbM.Checked)
- spol = 'M';
- else
- spol = 'F';
- SqlConnection conn = new SqlConnection("Data Source=192.168.26.14;Initial Catalog=stuslu;User ID=stuslu;Password=stuslu");
- conn.Open();
- string statement = "SELECT * FROM student WHERE (ime = '" + txtIme.Text + "' OR prezime = '" + txtPrezime.Text + "') AND spol = '" + spol +"';";
- SqlDataAdapter dataAdapter = new SqlDataAdapter(statement, conn);
- DataTable dt = new DataTable();
- dataAdapter.Fill(dt);
- dgvPodaci.DataSource = dt;
- conn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement