using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
namespace Csharp_Project
{
class DB
{
SqlConnection connection;
public DB()
{
connection = new SqlConnection(@"Data Source=RADEK-PC\SQLEXPRESS;Integrated Security=False;User ID=sa;Password=lewandowski");
}
public void openConnection()
{
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
}
public void closeConnection()
{
if (connection.State != ConnectionState.Closed)
{
connection.Close();
}
}
public DataTable getData(string procedureName, SqlParameter[] procedureParams)
{
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = procedureName;
command.Connection = connection;
if (procedureParams != null)
{
for (int i = 0; i < procedureParams.Length; i++)
{
command.Parameters.Add(procedureParams[i]);
}
}
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
return table;
}
public void setData(string procedureName, SqlParameter[] procedureParams)
{
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = procedureName;
command.Connection = connection;
if (procedureParams != null)
{
command.Parameters.AddRange(procedureParams);
}
command.ExecuteNonQuery();
}
}
}
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
return table;
tutaj wywala mi błąd i juz nie mam pojecia czemu a dokladnie brzmi on tak : An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Login failed for user 'sa'. Proszę was o pomoc.