Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Extracting a value from SQL to vb.net

Author  Topic 

John T.
Posting Yak Master

112 Posts

Posted - 2003-04-14 : 18:13:14
Would somebody show me how, for example, you would sum a column in your db and pass that value back to vb.net code to work with? This I can't seem to find anywhere that I look.
Thanks.

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2003-04-14 : 18:33:06
Here is a sample using ADO.NET's executescalar, its written in C# but shouldnt be hard to translate (but I'll leave that up to you )

SqlCommand sqlCmdGetNodeParent = new SqlCommand("dba0082.sprGetNodeParent", sqlConn);
sqlCmdGetNodeParent.CommandType = CommandType.StoredProcedure;

SqlParameter parNodeID = sqlCmdGetNodeParent.Parameters.Add("@NodeID", SqlDbType.Int, 4);
parNodeID.Value = intNodeID;

intParentNode = Convert.ToInt32(sqlCmdGetNodeParent.ExecuteScalar());
foo.Text = intParentNode.ToString();
sqlCmdGetNodeParent.Dispose();


You could also accomplish what you need with ADO.NET's ExecuteNonQuery method for a SqlCommand object.

There are alot of tutorials and examples at www.dotnetjunkies.com
I'd also try googling for "ado.net return value"

hth,
Justin

"Take care of yourself and do night fight with pygmies" - RT
Go to Top of Page

John T.
Posting Yak Master

112 Posts

Posted - 2003-04-14 : 19:52:25
Thanks very much for your reply.

Go to Top of Page
   

- Advertisement -