How can i refresh th database when i insert something (no datagrid view and no datasource)Identify t

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; background-color:#f5f5ff

<div id="x_post_message_2039032 Hello i make 2 function which with first Datareader i read from the database and from the another i edit the databases tables. here is the functions:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; public <span style="color:Blue; string DatabaseReader(<span style="color:Blue; string <span style="color:Blue; select, <span style="color:Blue; string read)
{
SqlConnection conn = <span style="color:Blue; new SqlConnection(<span style="color:#A31515; "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Users\Achill\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\basi.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand command = conn.CreateCommand();
command.CommandText = <span style="color:Blue; select;
<span style="color:Blue; bool syndesh = <span style="color:Blue; true;
<span style="color:Blue; try
{
conn.Open();
}
<span style="color:Blue; catch
{
showError(<span style="color:#A31515; "Αδύνατη σύνδεση με τη βάση δεδομένων");
syndesh = <span style="color:Blue; false;
}
<span style="color:Blue; if (syndesh)
{
SqlDataReader reader = command.ExecuteReader();
<span style="color:Blue; while (reader.Read()) <span style="color:Blue; return reader[read].ToString();
conn.Close();

}
<span style="color:Blue; return <span style="color:#A31515; "noData";
}
[/code]
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; public <span style="color:Blue; void DatabaseChange(<span style="color:Blue; string write)
{
SqlConnection conn = <span style="color:Blue; new SqlConnection(<span style="color:#A31515; "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Users\Achill\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\basi.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand command = conn.CreateCommand();
command.CommandText = write;
<span style="color:Blue; bool syndesh = <span style="color:Blue; true;
<span style="color:Blue; try
{
conn.Open();
}
<span style="color:Blue; catch
{
showError(<span style="color:#A31515; "Αδύνατη σύνδεση με τη βάση δεδομένων");
syndesh = <span style="color:Blue; false;
}
<span style="color:Blue; if (syndesh)
{
command.ExecuteNonQuery();
}
}
[/code]
<br/>
<br/>
<br/>
<br/>
<br/>
I want when i debug the program when i edit or add something from any table i want to refresh the database automaticaly and its not nesacary to close the program and open again to read it.<br/>
<br/>
here is an example to understand what i mean:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
DatabaseChange(<span style="color:#A31515; "insert into table (column1,column2) values (data1,data2)";
label1.Text = DatabaseReader(<span style="color:#A31515; "select data1 from


Hi All,
I am having the following funtion to validate the xml but I want to track the each and every element of xml whether it is valid/Invalid can you please tell me how to Identify the node is valid/not?

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <font size="2" color="#0000ff" style="color:#0000ff; font-size:x-small
Private
</font>
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Sub<span style="font-size:x-small Validate_1(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
filename <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small MemoryStream,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small xsc
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlSchemaCollection)<font size="2" style="font-size:x-small

m_success =
</font><font size="2" color="#0000ff <font size="2" color="#0000ff True</font></font>

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
Console.WriteLine()
Console.WriteLine("Validating XML file {0}...", filename.ToString())
filename.Position = 0
<font size="2" style="font-size:x-small
reader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlTextReader(filename)</font><span style="font-size:x-small <font size="2" style="font-size:x-small

</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small nodenm
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff String</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small

</font><font size="2" color="#008000 <font size="2" color="#008000 Create a validating reader.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
vreader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlValidatingReader(reader)</font><span style="font-size:x-small <font size="2" style="font-size:x-small

</font><font size="2" color="#008000 <font size="2" color="#008000 Use the schemas stored in the schema collection.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
vreader.Schemas.Add(xsc)
<font size="2" style="font-size:x-small

</font><font size="2" color="#008000 <font size="2" color="#008000 Set the validation event handler.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small

</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddHandler<span style="font-size:x-small vreader.ValidationEventHandler,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddressOf<font size="2 ValidationCallBack</font><span style="font-size:x-small <font size="2" style="font-size:x-small

</font><font size="2" color="#008000 <font size="2" color="#008000 Read and validate the XML data.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small

</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While<font size="2 vreader.Read()</font><span style="font-size:x-small <font size="2" style="font-size:x-small
nodenm = vreader.Name
</font><font size="2" color="#008000 <font size="2" color="#008000 LocalName())</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
MsgBox(nodenm)
<font size="2" style="font-size:x-small

</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff While</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
MsgBox("Validation finished. Validation" & m_success)
<hr class="sig Manoj A. Raut

View the full article
 
Back
Top