
AuxilioGF3
Publicado por Guillermo (8 intervenciones) el 14/10/2014 21:03:14
Como les va??, disculpen que los moleste, consulto sobre lo siguiente:
Debo llenar GridView con dato ingresado en TextBox, luego de apretar Boton Aceptar.....es decir....pongo los datos en TextBox, aprieto "Aceptar", y se me debe llenar GridView con los datos asociados a ese TextBox de la tabla....
Tengo el código que estoy usando, pero me da ERROR de "the connectionstring property has not been initialized"
¿Qué es lo que podría estar sucediendo, si esta bien el código, para llenar el GridView con dato Ingresado en TextBox después del Boton Aceptar????
"Por favor, si me pueden ayudar, me queda poco tiempo para presentar este trabajo como TESIS..........."
Mil millones de Gracias..........
Dejo el código que estoy usando: (y el del Web Config),:
protected void ButtonAceptar_Click(object sender, EventArgs e)
{
OleDbConnection connection;
OleDbCommand command;
OleDbDataAdapter Adaptador;
PersonC OldPerson = new PersonC();
connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Guillermo\Documents\Datos.accdb;Persist Security Info=False");
command = connection.CreateCommand();
int nf = 0;
nf = int.Parse(TextDni.Text);
try
{
OleDbConnection cnn = new OleDbConnection();
cnn.Open();
string query = "SELECT Nombre, Apellido FROM Alumno WHERE Dni LIKE '%" + nf + "%'";
OleDbCommand cmdd = new OleDbCommand(query, cnn);
cmdd.Parameters.AddWithValue("@Dni", nf);
//Dim dt As New DataTable
//adaptador.Fill(dt)
DataTable tabla = new DataTable();
Adaptador = new OleDbDataAdapter(cmdd);
Adaptador.Fill(tabla);
GridValidaAlum.DataSource = tabla;
GridValidaAlum.DataBind();
}
catch (Exception)
{
throw;
}
finally
{
if (connection != null)
{
connection.Close();
}
}
}
y aquí el del Web Config:
<configuration>
<appSettings>
<add key="Design.cs" />
</appSettings>
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=.\Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Guillermo\Documents\Datos.accdb;Persist Security Info=False"
providerName="System.Data.OleDb"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--<authentication mode="Forms">-->
<!--<forms loginUrl="~/Account/Login.aspx" timeout="2880" protection="All"/></authentication>-->
<authorization>
<deny users ="?" />
<allow users = '*' />
</authorization>
<membership>
<providers>
<clear/>
<add name="AspNetOleDbMembershipProvider" type="System.Web.Security.OleDbMembershipProvider" 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="AspNetOleDbProfileProvider" type="System.Web.Profile.OleDbProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetOleDbRoleProvider" type="System.Web.Security.OleDbRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Debo llenar GridView con dato ingresado en TextBox, luego de apretar Boton Aceptar.....es decir....pongo los datos en TextBox, aprieto "Aceptar", y se me debe llenar GridView con los datos asociados a ese TextBox de la tabla....
Tengo el código que estoy usando, pero me da ERROR de "the connectionstring property has not been initialized"
¿Qué es lo que podría estar sucediendo, si esta bien el código, para llenar el GridView con dato Ingresado en TextBox después del Boton Aceptar????
"Por favor, si me pueden ayudar, me queda poco tiempo para presentar este trabajo como TESIS..........."
Mil millones de Gracias..........
Dejo el código que estoy usando: (y el del Web Config),:
protected void ButtonAceptar_Click(object sender, EventArgs e)
{
OleDbConnection connection;
OleDbCommand command;
OleDbDataAdapter Adaptador;
PersonC OldPerson = new PersonC();
connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Guillermo\Documents\Datos.accdb;Persist Security Info=False");
command = connection.CreateCommand();
int nf = 0;
nf = int.Parse(TextDni.Text);
try
{
OleDbConnection cnn = new OleDbConnection();
cnn.Open();
string query = "SELECT Nombre, Apellido FROM Alumno WHERE Dni LIKE '%" + nf + "%'";
OleDbCommand cmdd = new OleDbCommand(query, cnn);
cmdd.Parameters.AddWithValue("@Dni", nf);
//Dim dt As New DataTable
//adaptador.Fill(dt)
DataTable tabla = new DataTable();
Adaptador = new OleDbDataAdapter(cmdd);
Adaptador.Fill(tabla);
GridValidaAlum.DataSource = tabla;
GridValidaAlum.DataBind();
}
catch (Exception)
{
throw;
}
finally
{
if (connection != null)
{
connection.Close();
}
}
}
y aquí el del Web Config:
<configuration>
<appSettings>
<add key="Design.cs" />
</appSettings>
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=.\Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Guillermo\Documents\Datos.accdb;Persist Security Info=False"
providerName="System.Data.OleDb"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--<authentication mode="Forms">-->
<!--<forms loginUrl="~/Account/Login.aspx" timeout="2880" protection="All"/></authentication>-->
<authorization>
<deny users ="?" />
<allow users = '*' />
</authorization>
<membership>
<providers>
<clear/>
<add name="AspNetOleDbMembershipProvider" type="System.Web.Security.OleDbMembershipProvider" 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="AspNetOleDbProfileProvider" type="System.Web.Profile.OleDbProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetOleDbRoleProvider" type="System.Web.Security.OleDbRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Valora esta pregunta


0