When I try to connect to DataBase, I get error: Key word doesn't support: Host.
int x = Int32.Parse(textBox1.Text);
try
{
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString =
Properties.Settings.Default.postgresConnectionString;
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "getCount";
System.Data.SqlClient.SqlParameter param = new System.Data.SqlClient.SqlParameter("@k",
SqlDbType.Int);
param.Direction = ParameterDirection.Output;
cmd.Parameters.Add(param);
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Tovar", x));
con.Open();
cmd.ExecuteNonQuery();
string kolvo = cmd.Parameters["@k"].Value.ToString();
con.Close();
label1.Text = kolvo + " израсходован в количестве ";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Connection String:
User Id=postgres;Password=8loz9fnl;Host=localhost;Database=postgres;Persist Security Info=True
I guess that you're using devart's dotconnect for ado.net connectivity so you should import Devart.Data.PostgreSql
and use PgSqlConnection
instead of sqlconnection
and pgsqlcommand
instead of sqlcommand