Usuário com melhor resposta
bom dia estou iniciando em post gres

Pergunta
-
como comverter este codigo para postgres
{
conecta.Conexao();
if (conecta.Con != null)
{
using (SqlConnection con = new SqlConnection(conecta.Con.ConnectionString))
{
try
{
SqlCommand cmd = new SqlCommand("SELECT CategoryID, CategoryName, Description FROM Categories", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataBind();
}
catch (SqlException)
{
}
finally
{
if (con != null)
{
con.Close();
}
}
}
}
}
Respostas
-
Guilherme, bom dia
De uma olhada nesses links aqui, podem te ajudar
http://www.devmedia.com.br/asp-net-e-postgresql/14067
http://www.codeproject.com/Articles/30989/Using-PostgreSQL-in-your-C-NET-application-An-intr
Bruno Viegas D. Ribeiro
Analista Desenvolvedor de Sistemas www.brunoviegas.com.br- Marcado como Resposta Ricardo RussoModerator segunda-feira, 14 de janeiro de 2013 13:13
Todas as Respostas
-
Guilherme, bom dia
De uma olhada nesses links aqui, podem te ajudar
http://www.devmedia.com.br/asp-net-e-postgresql/14067
http://www.codeproject.com/Articles/30989/Using-PostgreSQL-in-your-C-NET-application-An-intr
Bruno Viegas D. Ribeiro
Analista Desenvolvedor de Sistemas www.brunoviegas.com.br- Marcado como Resposta Ricardo RussoModerator segunda-feira, 14 de janeiro de 2013 13:13
-
Você olhou o link que eu te mandei?
Nele tem uma parte onde mostra um método de consulta,
Você vai precisar trocar todas as classes que começam por SQL e colocar Npgsql.
Bruno Viegas D. Ribeiro
Analista Desenvolvedor de Sistemas www.brunoviegas.com.br -
-
ta dando um erro no codigo vo postar imagem do local e o erro que aparece quem puder me ajudarusing System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SaeInfo { public partial class Proservi : System.Web.UI.Page { private DropDownList DropDownList1; private DropDownList DropDownlist2; private DropDownList DropDownlist3; private DropDownList DropDownList8; //erro ta na linha superior dropdowlist8//descriçao do erro// field'saeinfo.proservi.dropdownlist8' is never assigned to , and will always have its default proservi.aspx line 15 col 30 protected void Page_Load(object sender, EventArgs e) { { { if (!IsPostBack) { DropDownList8.Items.Clear(); swotEntities db = new swotEntities(); var query = from c in db.grupodeestoque select c; int x = 0; DropDownList8.Items.Insert(0, ""); DropDownList8.Items[0].Value = ""; foreach (var item in query) { x++; DropDownList8.Items.Insert(x, item.idgrupodeestoque.ToString() + "-" + item.descrgrupodeestoque.ToString()); DropDownList8.Items[x].Value = item.idgrupodeestoque.ToString(); } } } } } protected void DropDownList1_Init(object sender, EventArgs e) { DropDownList1 = sender as DropDownList; } protected void DropDownList2(object sender, EventArgs e) { DropDownlist2 = sender as DropDownList; } protected void DropDownList3(object sender, EventArgs e) { DropDownlist3 = sender as DropDownList; } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { ImageButton lkbDelete; Label lbtipo; Label lbdescrtipo; Label lbsit; Label lbdescrsit; if (e.Row.RowType == DataControlRowType.DataRow) { lkbDelete = (ImageButton)e.Row.FindControl("imgbtdelete");//fazemos uma referência ao botão delete criado automaticamente if (lkbDelete != null) { string cliente = e.Row.Cells[2].Text; string prompt = "javascript:return confirm('Deseja realmente excluir o registro " + "?')"; lkbDelete.Attributes.Add("onClick", prompt); } lbtipo = (Label)e.Row.FindControl("lbtipo"); lbdescrtipo = (Label)e.Row.FindControl("lbdescrtipo"); if (lbtipo != null) { lbdescrtipo.Text = "Não Informado"; if (lbtipo.Text == "S") { lbdescrtipo.Text = "Serviço"; } if (lbtipo.Text == "P") { lbdescrtipo.Text = "Produto"; } lbsit = (Label)e.Row.FindControl("lbsit"); lbdescrsit = (Label)e.Row.FindControl("lbdescrsit"); if (lbtipo != null) { lbdescrsit.Text = "Não Informado"; if (lbsit.Text == "A") { lbdescrsit.Text = "Ativo"; } if (lbsit.Text == "I") { lbdescrsit.Text = "Inativo"; } } } } } protected void BtnInsereCurso_Click(object sender, EventArgs e) { lista.Visible = false; addadicionar.Visible = true; } protected void Button2_Click(object sender, EventArgs e) { lista.Visible = true; addadicionar.Visible = false; } protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { lista.Visible = true; addadicionar.Visible = false; GridView1.DataBind(); } protected void DetailsView1_ModeChanged(object sender, EventArgs e) { lista.Visible = true; addadicionar.Visible = false; GridView1.DataBind(); } protected void DropDownList9_Init(object sender, EventArgs e) { DropDownlist3 = sender as DropDownList; } protected void DropDownList8_SelectedIndexChanged(object sender, EventArgs e) { } }