[ LakiETF @ 28.03.2011. 08:44 ] @
Situacija je ovakva:

Imam bazu podataka koju cine dve tabele: vozac-primarni kljuc je maticni broj, vozilo - primarni kljuc je registarski broj, spoljni kljuc je maticni broj.

Ovo su tabele:

http://img852.imageshack.us/i/vozac.png/
http://img194.imageshack.us/i/vozilo.png/

Hocu asp.net stranicu sa dropdown listom, kao na slici:

http://img339.imageshack.us/i/previewkt.png/

Do ove tacke nema nikakvih problema, moj C# kod je sledeci:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string selectSQL;
selectSQL = "SELECT * FROM Vozac";
selectSQL += "WHERE MaticniBroj ='" + DropDownList1.SelectedItem.Value + "'";

string baza_podatakaConnectionString = @"Data Source = localhost\\SQLEXPRESS;" +
"Initial Catalog = baza_podataka; Integrated Security = SSPI";
SqlConnection con = new SqlConnection(baza_podatakaConnectionString);
SqlCommand cmd = new SqlCommand(selectSQL, con);
SqlDataReader reader;


// Otvaranje Baze podataka i pokusaj citanja

try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();

// Pravljenje stringa sa zapisima o selektovanom vozacu:

SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();
sb.Add(baza_podatakaConnectionString, reader["Ime"]);
sb.Add(baza_podatakaConnectionString, reader["Prezime"]);

Label1.Text = sb.ToString();

reader.Close();
}
catch (Exception err)
{
Label1.Text = "Greska!!!";
}
finally
{
con.Close();
}



}
}



E, kada uradim build solution i kada ovo pokrenem, zakljucim da mi NIKADA program ne ulazi u ovaj try deo koda, vec uvek izbacuje poruku iz Catch dela.

Gde gresim?

Inace, sadrzaj web.config fajla mi je:(ako je bitno)

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<connectionStrings>
<add name="baza_podatakaConnectionString" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=baza_podataka;Integrated Security=True;Pooling=False"
providerName="System.Data.SqlClient" />
</connectionStrings>

<system.web>
<compilation debug="false" targetFramework="4.0" />

<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>

<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>

<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>

<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>

</system.web>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
[ dejanet @ 28.03.2011. 08:54 ] @
Prvo moras da znas koja je greska, znaci u catch delu umesto
Label1.Text = "Greska!!!";

stavi

Label1.Text = err.ToString();

ili stavi breakpoint pa procitaj gresku.. onda ces i sam verovatno resiti problem..