1 / 1 / 0
Регистрация: 09.02.2013
Сообщений: 26
|
|
1
|
C# поиск
22.06.2014, 18:22. Показов 522. Ответов 0
помогите Пожалуйста доделать поиск
C# | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| 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;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace database
{
public partial class Form1 : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
string commandText = "SELECT * FROM Найменование";
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"Database4.accdb";
string commandText2 =
"SELECT *" + "FROM [nam]";
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
cn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\users\укенук\documents\visual studio 2010\Projects\database\database\Database4.accdb"; // TODO: данная строка кода позволяет загрузить данные в таблицу "database4DataSet.Склад". При необходимости она может быть перемещена или удалена.
cmd.Connection = cn;
this.складTableAdapter.Fill(this.database4DataSet.Склад);
}
private void button1_Click(object sender, EventArgs e)
{
this.складTableAdapter.Update(this.database4DataSet);
}
private void пошукТоваруToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.складTableAdapter.ПошукТовару(this.database4DataSet.Склад);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void пошукToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.складTableAdapter.Пошук(this.database4DataSet.Склад);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void пошукТоваруToolStripButton_Click_1(object sender, EventArgs e)
{
try
{
this.складTableAdapter.ПошукТовару(this.database4DataSet.Склад);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void button2_Click_1(object sender, EventArgs e)
{
try
{
listBox1.Items.Clear();
cmd.CommandText = textBox1.Text.ToString();
cn.Open();
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
listBox1.Items.Add(dr[0].ToString());
}
}
else { listBox1.Items.Add("Не знайдено даних!!!"); }
cn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
cn.Close();
}
}
}
} |
|
0
|