Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
Select IMAGE from SQL BASE to picturebox C#
Goran Bibic
6y
554
1
Reply
Code working fine
I need to put picture from sql to picturebox in my code
private
void
prijavaAction()
//04.04. final doradjena perfect
{
{
SqlConnection con =
new
SqlConnection(cs);
if
(textBox1.Text.All(
char
.IsDigit))
{
string queryString =
"SELECT [ime_prezime] FROM dbo.radnici WHERE bar_kod = '"
+ textBox1.Text +
"'"
;
// pronaci radnika u bazi
using
(SqlConnection connection =
new
SqlConnection(cs))
{
SqlCommand command =
new
SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
string commanda =
"select case when (SELECT (DATEDIFF(SECOND, Max(vrijemeprijave), GETDATE()) / 60) from dbo.prijava_radnika where status='prijavljen' and radnik= ("
+ queryString +
")) < 5 THEN 1 ELSE 0 END"
;
SqlConnection connection3 =
new
SqlConnection(cs);
SqlCommand command2 =
new
SqlCommand(commanda, connection3);
connection3.Open();
int
broj = Convert.ToInt32(command2.ExecuteScalar());
string commanda2 =
"select case when (SELECT (DATEDIFF(SECOND, Max(vrijemeodjave), GETDATE()) / 60) from dbo.prijava_radnika where status='odjavljen' and radnik= ("
+ queryString +
")) < 5 THEN 1 ELSE 0 END"
;
SqlConnection connection4 =
new
SqlConnection(cs);
SqlCommand command4 =
new
SqlCommand(commanda2, connection4);
connection4.Open();
int
broj2 = Convert.ToInt32(command4.ExecuteScalar());
if
(broj == 1 || broj2 == 1)
{
notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#FD7400"
);
messageLabel.Text =
"Prijava i odjava su blokirani 5 minuta \nza ovog radnika"
;
textBox1.Text =
""
;
}
else
{
try
{
if
(reader.Read())
{
string prijava =
"SELECT count(*) from dbo.prijava_radnika where vrijemeprijave is not null and vrijemeodjave is null and radnik = '"
+ readerresultTextbox.Text +
"' and redni_broj is NULL"
;
SqlCommand provjeraprijaveradnika =
new
SqlCommand(prijava, con);
con.Open();
int
result = Convert.ToInt32(provjeraprijaveradnika.ExecuteScalar());
con.Close();
if
((result == 0))
{
String saveStaff =
"INSERT INTO dbo.prijava_radnika (vrijemeprijave, status, radnik,idfakture) VALUES(@vrijemeprijave,'prijavljen', '"
+ readerresultTextbox.Text +
"',@idfakture)"
;
using
(SqlConnection openCon2 =
new
SqlConnection(cs))
{
using
(SqlCommand querySaveStaff =
new
SqlCommand(saveStaff))
{
querySaveStaff.Connection = openCon2;
querySaveStaff.Parameters.Add(
"@vrijemeprijave"
, SqlDbType.DateTime).Value = DateTime.Now;
querySaveStaff.Parameters.Add(
"@idfakture"
, SqlDbType.Int).Value = id_fakture;
openCon2.Open();
querySaveStaff.ExecuteNonQuery();
openCon2.Close();
notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#2EFF36"
);
// messageLabel.Text = (reader["ime_prezime"].ToString()) + " je prijavljen u \n " + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss");
messageLabel.Text = (
"Dobro došli na posao...\n"
+ reader[
"ime_prezime"
].ToString()) +
" \nPrijavljeni ste od\n "
+ DateTime.Now.ToString(
"dd.MM.yyyy HH:mm:ss"
);
readerresultTextbox.Text = (reader[
"ime_prezime"
].ToString());
}
}
}
else
{
String updateStaff =
" declare @maxNo integer = 0 select @maxNo = isnull(max(redni_broj), 0) from[dbo].[prijava_radnika] UPDATE[dbo].[prijava_radnika] SET"
+
" [vrijemeodjave] = @vrijemeodjave,[redni_broj] = (@maxNo+1),[status] = 'odjavljen' WHERE radnik = '"
+ readerresultTextbox.Text +
"'and [status] = 'prijavljen'"
;
using
(SqlConnection connection1 =
new
SqlConnection(cs))
{
SqlCommand command1 =
new
SqlCommand(queryString, connection1);
connection1.Open();
SqlDataReader reader1 = command1.ExecuteReader();
connection.Close();
try
{
if
(reader1.Read())
{
using
(SqlConnection openCon3 =
new
SqlConnection(cs))
{
using
(SqlCommand queryupdateStaff =
new
SqlCommand(updateStaff))
{
queryupdateStaff.Connection = openCon3;
queryupdateStaff.Parameters.Add(
"@vrijemeodjave"
, SqlDbType.DateTime).Value = DateTime.Now;
openCon3.Open();
queryupdateStaff.ExecuteNonQuery();
openCon3.Close();
}
}
notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#FFE11A"
);
messageLabel.Text = (reader1[
"ime_prezime"
].ToString()) +
" je odjavljen u \n "
+ DateTime.Now.ToString(
"dd.MM.yyyy HH:mm:ss"
);
}
}
catch
{ }
}
reader.Close();
}
}
else
{
notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#FD7400"
);
messageLabel.Text =
"Radnik ne postoji u bazi! \nProverite vašu karticu ili probajte ponovo!"
;
textBox1.Text =
""
;
}
}
finally
{
}
}
}
}
else
{
notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#FD7400"
);
messageLabel.Text =
"Bar kod nije važeci ili nije bar kod"
;
textBox1.Text =
""
;
}
}
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to Check Table Cell Value
Database structure for advance/due payment