Showing posts with label couple. Show all posts
Showing posts with label couple. Show all posts

Friday, March 23, 2012

Refresh a windows form without closing it

Hi all

I have a couple of windows forms which share tables or parts of tables.

When I edit a tables data on one form (form2), where it ,s data is linked to another form ( form1), when I go back to form1 I find that the fields have not been updated until I close the form and reopen it.

Is there a way to refresh the field on form1 by using a button in the menu bar and what would the code behind look like. I use vb .

Thanks

Rob

You can create a button and then in the click event use:

me.refresh which will refresh the whole form, or you can do controlname.refresh which will refresh just the specific control.

|||

Hi

Thanks for your help so far. I have tried the "me. refresh ()" but nothing happens.

I have also added a few things ( as below) to the code to try and get my dataset to refresh , but still without succsess . Can you suggest any other code snippit which I can add to the me.refresh() which would refresh the data in the client dataset.

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

Me.Refresh = ProjectManagmentDataSet1.Client()

End Sub

Thanks

Rob

|||You need to re-fill the dataset. If you are using a table adapter, it would be like the following:

Code Snippet

Me.MyTableAdapter.Fill(Me.MyDataSet.MyTable)

If you look in the Form_Load event, this is usually where the code is located that will load your data. You can simply copy those steps into the ToolStipButton1_Click event. Once the dataset has been re-filled, use Me.Refresh() to refresh the form. If that doesn't make sense, could you post the code that you are using to load the data into your form?

|||

Thanks for your patience so far

Public Class Form2

Private Sub ClientBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClientBindingNavigatorSaveItem.Click

Me.Validate()

Me.ClientBindingSource.EndEdit()

Me.ClientTableAdapter.Update(Me.ProjectManagmentDataSet1.Client)

Me.SHIPSBindingSource.EndEdit()

Me.SHIPSTableAdapter.Update(Me.ProjectManagmentDataSet1.SHIPS)

End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'TODO: This line of code loads data into the 'ProjectManagmentDataSet1.SHIPS' table. You can move, or remove it, as needed.

Me.SHIPSTableAdapter.Fill(Me.ProjectManagmentDataSet1.SHIPS)

'TODO: This line of code loads data into the 'ProjectManagmentDataSet1.Client' table. You can move, or remove it, as needed.

Me.ClientTableAdapter.Fill(Me.ProjectManagmentDataSet1.Client)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Client.Show()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Form1.Show()

End Sub

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

Me.Refresh()

End Sub

End Class

|||

Can you show me the code for Form1 as well? I think that is where we need to do the updating. If I understand your question correctly, you edit in Form2 and need it to update into Form1 without having to close and re-open Form1.

One other item that is not really a huge thing but you may want to change the ClientBindingNavigatorSaveItem_Click to the following:

Private Sub ClientBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClientBindingNavigatorSaveItem.Click

Try

Me.Validate()

Me.ClientBindingSource.EndEdit()

Me.ClientTableAdapter.Update(Me.ProjectManagmentDataSet1.Client)

Me.SHIPSBindingSource.EndEdit()

Me.SHIPSTableAdapter.Update(Me.ProjectManagmentDataSet1.SHIPS)

Catch ex as Exception

MsgBox("Update Failed: " & ex.ToString)

End Try

End Sub

This will pop up a message box with an explanation as to why the database was not able to be updated if there is a problem updating the data.

|||

This is as far as I have gotten. I edit in form1and hope to refresh form2 without closing and reopening.

I have no problem with updating the data , just the long rout around of closing and reopening forms.

Regards

Rob

|||

OK, the code in form2 should be like the following:

Code Snippet

Public Class Form2

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Call loadData()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Client.Show()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Form1.Show()

End Sub

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

Call loadData()

Me.Refresh()

End Sub

Private Sub loadData()

Me.SHIPSTableAdapter.Fill(Me.ProjectManagmentDataSet1.SHIPS)

Me.ClientTableAdapter.Fill(Me.ProjectManagmentDataSet1.Client)

End Sub

End Class

You shouldn't need the "save" part of the code in form2, just in form1. All you need to do is to fill the adapters again and then refresh the form.

|||Thanks ,all sorted out.

Wednesday, March 21, 2012

Referential Integrity

Hi All
I have a DB , when i go into Diagrams & create the diagrams I can see
that a couple of tables have referntial integrity ... I want to create
a script ... that would let me knw the no. of tables that do not have
referentail integrity ...
Has some got that kind of script
ThanksHi
Do you mean tables that do not have PK,and FK?
"Double_B" <bharatbutani@.gmail.com> wrote in message
news:1153716353.700403.319830@.b28g2000cwb.googlegroups.com...
> Hi All
> I have a DB , when i go into Diagrams & create the diagrams I can see
> that a couple of tables have referntial integrity ... I want to create
> a script ... that would let me knw the no. of tables that do not have
> referentail integrity ...
> Has some got that kind of script
> Thanks
>|||Yess
Uri Dimant wrote:
> Hi
> Do you mean tables that do not have PK,and FK?
>
> "Double_B" <bharatbutani@.gmail.com> wrote in message
> news:1153716353.700403.319830@.b28g2000cwb.googlegroups.com...
> > Hi All
> >
> > I have a DB , when i go into Diagrams & create the diagrams I can see
> > that a couple of tables have referntial integrity ... I want to create
> > a script ... that would let me knw the no. of tables that do not have
> > referentail integrity ...
> >
> > Has some got that kind of script
> >
> > Thanks
> >|||Hi
SELECT
name TableName
FROM
sysobjects
WHERE
type = 'U'
AND ( OBJECTPROPERTY(sysobjects.id , 'IsPrimaryKey' ) = 0 OR
OBJECTPROPERTY(sysobjects.id , 'IsForeignKey' ) = 0 )
"Double_B" <bharatbutani@.gmail.com> wrote in message
news:1154002811.976393.60290@.h48g2000cwc.googlegroups.com...
> Yess
>
>
>
> Uri Dimant wrote:
>> Hi
>> Do you mean tables that do not have PK,and FK?
>>
>> "Double_B" <bharatbutani@.gmail.com> wrote in message
>> news:1153716353.700403.319830@.b28g2000cwb.googlegroups.com...
>> > Hi All
>> >
>> > I have a DB , when i go into Diagrams & create the diagrams I can see
>> > that a couple of tables have referntial integrity ... I want to create
>> > a script ... that would let me knw the no. of tables that do not have
>> > referentail integrity ...
>> >
>> > Has some got that kind of script
>> >
>> > Thanks
>> >
>

Referential Integrity

Hi All
I have a DB , when i go into Diagrams & create the diagrams I can see
that a couple of tables have referntial integrity ... I want to create
a script ... that would let me knw the no. of tables that do not have
referentail integrity ...
Has some got that kind of script
ThanksHi
Do you mean tables that do not have PK,and FK?
"Double_B" <bharatbutani@.gmail.com> wrote in message
news:1153716353.700403.319830@.b28g2000cwb.googlegroups.com...
> Hi All
> I have a DB , when i go into Diagrams & create the diagrams I can see
> that a couple of tables have referntial integrity ... I want to create
> a script ... that would let me knw the no. of tables that do not have
> referentail integrity ...
> Has some got that kind of script
> Thanks
>|||Yess
Uri Dimant wrote:[vbcol=seagreen]
> Hi
> Do you mean tables that do not have PK,and FK?
>
> "Double_B" <bharatbutani@.gmail.com> wrote in message
> news:1153716353.700403.319830@.b28g2000cwb.googlegroups.com...|||Hi
SELECT
name TableName
FROM
sysobjects
WHERE
type = 'U'
AND ( OBJECTPROPERTY(sysobjects.id , 'IsPrimaryKey' ) = 0 OR
OBJECTPROPERTY(sysobjects.id , 'IsForeignKey' ) = 0 )
"Double_B" <bharatbutani@.gmail.com> wrote in message
news:1154002811.976393.60290@.h48g2000cwc.googlegroups.com...
> Yess
>
>
>
> Uri Dimant wrote:
>|||SQL Server has a basic data modeler (diagrams) that allows you to create
foreign keys between tables. It is not as nice or powerful as Erwin, but it
gets the job done (and it is free).
If you want to stick with Microsoft products you could try using Visio. I
remember seeing database diagramming capabilities in some of the versions.
I haven't looked at the new Visual Studio offering, but they might have
something in there:
http://msdn.microsoft.com/vstudio/t...ro/default.aspx
Here are a few other tools that I am aware of:
WinSQL
http://synametrics.com/SynametricsWebApp/WinSQL.jsp
SQL Diagrams
http://www.skilledsoftware.com/sqldiagrams.htm
Keith Kratochvil
"Patrick" <Patrick@.discussions.microsoft.com> wrote in message
news:059856C5-B1EE-481D-A301-A93D62E11EAD@.microsoft.com...
> We are currently using Erwin for our Data Modeler, but wanted to know if
> there are any good tools, or better data modelers, to help with our
> project
> of referential integrity. Currently we use triggers to enforce our
> referential integrity, but we would like to move towards using constraints
> to
> enforce our data integrity. Currently using SQL Server 2000.

Saturday, February 25, 2012

reduce trans log size; help needed

Hello,

I am hoping you can help me with the following problem; I need to process
the following steps every couple of hours in order to keep our Sql 2000
database a small as possible (the transaction log is 5x bigger than the db).

1.back-up the entire database
2.truncate the log
3.shrink the log
4.back-up once again.

As you may have determined, I am relatively new to managing a sql server
database and while I have found multiple articles online about the topics I
need to accomplish, I cannot find any actual examples that explain where I
input the coded used to accomplish the above-mentioned steps. I do
understand the theory behind the steps I just do not know how to accomplish
them!

If you know of a well-documented tutorial (Aside from Books Online (F1)),
please point me in the right direction.

Regards.First, create a backup device with whatever name you want. ( I assume you
know how to do this).
Might have to check the syntax on each of these but here goes

1. backup database [your_database_name] to [your_backup_device] with stats,
init
2. backup tran [your_database_name] to [your_backup_device]
3. dbcc shrinkfile 2,truncateonly
4. backup database [your_database_name] to [your_backup_device]

Step 3 above assumes that file 2 is the logfile for your database. You
might have to check this by issuing a select * from sysfiles (in query
analyzer) to make sure that file 2 is the log file.

Hope this helps.

Oscar...

> 1.back-up the entire database
> 2.truncate the log
> 3.shrink the log
> 4.back-up once again.
> As you may have determined, I am relatively new to managing a sql server
> database and while I have found multiple articles online about the topics
I
> need to accomplish, I cannot find any actual examples that explain where I
> input the coded used to accomplish the above-mentioned steps. I do
> understand the theory behind the steps I just do not know how to
accomplish
> them!

reduce trans log size; help needed

Hello,
I am hoping you can help me with the following problem; I need to process
the following steps every couple of hours in order to keep our Sql 2000
database a small as possible (the transaction log is 5x bigger than the db).
1.back-up the entire database
2.truncate the log
3.shrink the log
4.back-up once again.
As you may have determined, I am relatively new to managing a sql server
database and while I have found multiple articles online about the topics I
need to accomplish, I cannot find any actual examples that explain where I
input the coded used to accomplish the above-mentioned steps. I do
understand the theory behind the steps I just do not know how to accomplish
them!
If you know of a well-documented tutorial (Aside from Books Online (F1)),
please point me in the right direction.
Regards.| Hello,
|
| I am hoping you can help me with the following problem; I need to process
| the following steps every couple of hours in order to keep our Sql 2000
| database a small as possible (the transaction log is 5x bigger than the
db).
|
| 1.back-up the entire database
| 2.truncate the log
| 3.shrink the log
| 4.back-up once again.
|
| As you may have determined, I am relatively new to managing a sql server
| database and while I have found multiple articles online about the topics
I
| need to accomplish, I cannot find any actual examples that explain where I
| input the coded used to accomplish the above-mentioned steps. I do
| understand the theory behind the steps I just do not know how to
accomplish
| them!
--
You can create a job that executes the above steps every couple of hours.
You can define each of the above steps as actual job steps with the job.
You can use Enterprise Manager to create this job.
Hope this helps,
--
Eric Cárdenas
SQL Server support