Showing posts with label articles. Show all posts
Showing posts with label articles. Show all posts

Friday, March 23, 2012

How to make a diagram from data in a SQL Server table?

Hi all,

I′m a real SQL rookie and after two days of intensive research and reading of dozens of articles and web pages a bit confused about all that knowledge concerning database technology ... and I only want to do something very easy ...

Now, my question is, how can I produce a diagram from that data, that is stored in a table, maybe called "DiagData1"?

I have installed SQL Server Express 2005 and Visual Basic Express 2005 and did some first steps with it as where shown in an brilliant tutorial that I′ve found on a Microsoft (?) webpage. It shows the complete way building a database and connecting it to a form which was build with Visual Basic. So all what is left is find out how the database tables are connected to a diagram.

thanks′n greets,

VBFan

Hi all,

after long hours of reading and testing there′s some success now. Taking some lines from the online help I′ve done the following VB-prog that produces lines on the form when the button is pushed.

Now I would like to know how the button can be added by the prog at runtime. When I try it with the lines, that are commented out, I get an error.

Does anybody have the solution?

Thank you and greetings,

VBFan

Public Class Form1

Dim clI As Integer = 0

' Private Button1 As New Button()

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

' Me.Controls.Add(Button1)

' Button1.Height = 100

' Button1.Text = "Draw Line"

'End Sub

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

Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)

Dim formGraphics As System.Drawing.Graphics

formGraphics = Me.CreateGraphics()

formGraphics.DrawLine(myPen, 0, 0, 200, 200 + clI)

clI = clI + 10

myPen.Dispose()

formGraphics.Dispose()

End Sub

End Class

sql

Friday, February 24, 2012

How to know the next ID ?I

Hi all,

is it possible to know the next record's identifier of a table without inserting it? I tried with SELECT MAX(ArticleID) FROM Articles but imagine that there is no record in the table (but there was of it), the SELECT MAX statement return a null value...

Thanks in advance,

Gilles
Why do you need the next id ? What datatype is the column ? Does it have the identity property ? Normally there is no need to get the next id prior to a transaction.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||If you just want to know the next value, then try the DBCC CHECKIDENT statement. Here's an example:

DBCC CHECKIDENT ('dbo.TableName', NORESEED )

Have a look here for details: http://msdn2.microsoft.com/en-US/library/ms176057(SQL.90).aspx

If you need this value programatically, then I might suggest that you may be doing something incorrectly, as this value shouldn't be required... (this functionality is meant to be hidden by the system - it's a key value only, and shouldn't be manipulated).|||

Hi,

You are right both... But, in fact, it's just to display an information. 'cause my application can add an "estimate" (I don't know the correct word in english) or an invoice and I'd like to display the next identifier so that it serf of reference... But it's a detail...

Thank you for your contribution

Gilles

|||If you really need to do that, then I'd suggest using something like this:

SELECT (ISNULL(MAX(IdntityColumnName), 0) + 1) AS NextId FROM [TableName]

... of course keeping in mind that if two people are using your app at the same time, they'll both get the same 'estimated' ID. This example is also assuming that your identitiy records are incremented by 1 (the default, but not the necessity).|||You have to keep in mind that this estimated id is only "safe" in a oneuser enviroment, due to the already mentioned reasons by Christoph. It is NOT preferable to use that in these days, because normally more than one user will connect to a database to manipulate the data (if not now, perhaps later, themost application are brought to a wider usergroup over the time and therefore ported from a one user enviroment, and its the heck to correct all this when your application is established and stable)

Better use Transaction, whereas you get a transaction scope the next ID, while locking the table for other users to prevent the concurrency conflicts.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||

Yes, that's right... but i think about what you write and, initialy, it will be a single user application... The problem is I don't have your level about programming SQL. I can work with ADO.Net but I don't know enough to do advanced stored procedure...

Thank you very much for your support. Now I know that such things exist and I'll be able to be interested in it later...

Thanks and have a good nigth...

PS : Can you just tell me where I can watch to study the things that you talked about... Thanks

Gilles

|||For most Microsoft development products, simply do a Google search for "Quickstart Tutorial" - there's usually something there. Tutorials are an easy way to learn.

For ADO.NET / SQL, have a look at:
http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/ADOPlusOverview.aspx|||

Hi Gilles,

Try this instead: "SELECT IDENT_CURRENT('tableName') AS currentIdentity"

That must work.

How to know the next ID ?

Hi all,


is it possible to know the next record's identifier of a

table without inserting it?

I tried with SELECT MAX(ArticleID) FROM Articles but imagine that there is no record in the table (but there was of it), the SELECT MAX statement return a null value...

Thanks in advance,

Gilles

Why do you need the next id ? What datatype is the column ? Does it have the identity property ? Normally there is no need to get the next id prior to a transaction.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||If you just want to know the next value, then try the DBCC CHECKIDENT statement. Here's an example:

DBCC CHECKIDENT ('dbo.TableName', NORESEED )

Have a look here for details: http://msdn2.microsoft.com/en-US/library/ms176057(SQL.90).aspx

If you need this value programatically, then I might suggest that you may be doing something incorrectly, as this value shouldn't be required... (this functionality is meant to be hidden by the system - it's a key value only, and shouldn't be manipulated).|||

Hi,

You are right both... But, in fact, it's just to display an information. 'cause my application can add an "estimate" (I don't know the correct word in english) or an invoice and I'd like to display the next identifier so that it serf of reference... But it's a detail...

Thank you for your contribution

Gilles

|||If you really need to do that, then I'd suggest using something like this:

SELECT (ISNULL(MAX(IdntityColumnName), 0) + 1) AS NextId FROM [TableName]

... of course keeping in mind that if two people are using your app at the same time, they'll both get the same 'estimated' ID. This example is also assuming that your identitiy records are incremented by 1 (the default, but not the necessity).|||You have to keep in mind that this estimated id is only "safe" in a oneuser enviroment, due to the already mentioned reasons by Christoph. It is NOT preferable to use that in these days, because normally more than one user will connect to a database to manipulate the data (if not now, perhaps later, themost application are brought to a wider usergroup over the time and therefore ported from a one user enviroment, and its the heck to correct all this when your application is established and stable)

Better use Transaction, whereas you get a transaction scope the next ID, while locking the table for other users to prevent the concurrency conflicts.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||

Yes, that's right... but i think about what you write and, initialy, it will be a single user application... The problem is I don't have your level about programming SQL. I can work with ADO.Net but I don't know enough to do advanced stored procedure...

Thank you very much for your support. Now I know that such things exist and I'll be able to be interested in it later...

Thanks and have a good nigth...

PS : Can you just tell me where I can watch to study the things that you talked about... Thanks

Gilles

|||For most Microsoft development products, simply do a Google search for "Quickstart Tutorial" - there's usually something there. Tutorials are an easy way to learn.

For ADO.NET / SQL, have a look at:
http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/ADOPlusOverview.aspx|||

Hi Gilles,

Try this instead: "SELECT IDENT_CURRENT('tableName') AS currentIdentity"

That must work.

How to know the next ID ?

Hi all,

is it possible to know the next record's identifier of a table without inserting it? I tried with SELECT MAX(ArticleID) FROM Articles but imagine that there is no record in the table (but there was of it), the SELECT MAX statement return a null value...

Thanks in advance,

Gilles
Why do you need the next id ? What datatype is the column ? Does it have the identity property ? Normally there is no need to get the next id prior to a transaction.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||If you just want to know the next value, then try the DBCC CHECKIDENT statement. Here's an example:

DBCC CHECKIDENT ('dbo.TableName', NORESEED )

Have a look here for details: http://msdn2.microsoft.com/en-US/library/ms176057(SQL.90).aspx

If you need this value programatically, then I might suggest that you may be doing something incorrectly, as this value shouldn't be required... (this functionality is meant to be hidden by the system - it's a key value only, and shouldn't be manipulated).|||

Hi,

You are right both... But, in fact, it's just to display an information. 'cause my application can add an "estimate" (I don't know the correct word in english) or an invoice and I'd like to display the next identifier so that it serf of reference... But it's a detail...

Thank you for your contribution

Gilles

|||If you really need to do that, then I'd suggest using something like this:

SELECT (ISNULL(MAX(IdntityColumnName), 0) + 1) AS NextId FROM [TableName]

... of course keeping in mind that if two people are using your app at the same time, they'll both get the same 'estimated' ID. This example is also assuming that your identitiy records are incremented by 1 (the default, but not the necessity).|||You have to keep in mind that this estimated id is only "safe" in a oneuser enviroment, due to the already mentioned reasons by Christoph. It is NOT preferable to use that in these days, because normally more than one user will connect to a database to manipulate the data (if not now, perhaps later, themost application are brought to a wider usergroup over the time and therefore ported from a one user enviroment, and its the heck to correct all this when your application is established and stable)

Better use Transaction, whereas you get a transaction scope the next ID, while locking the table for other users to prevent the concurrency conflicts.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||

Yes, that's right... but i think about what you write and, initialy, it will be a single user application... The problem is I don't have your level about programming SQL. I can work with ADO.Net but I don't know enough to do advanced stored procedure...

Thank you very much for your support. Now I know that such things exist and I'll be able to be interested in it later...

Thanks and have a good nigth...

PS : Can you just tell me where I can watch to study the things that you talked about... Thanks

Gilles

|||For most Microsoft development products, simply do a Google search for "Quickstart Tutorial" - there's usually something there. Tutorials are an easy way to learn.

For ADO.NET / SQL, have a look at:
http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/ADOPlusOverview.aspx|||

Hi Gilles,

Try this instead: "SELECT IDENT_CURRENT('tableName') AS currentIdentity"

That must work.