|
Hi,
I am using datasets to work with the data and populate text boxes appropriately. Something like:
textBox1.Text = dataset.table["tableName"].Row[0].column["LastName"]
In some books, they do databinding like:
textBox.DataBindings.Add("Text", _
table, table.Columns(I).ColumnName)
Which of these methods is better to get used to?
Are these two methods basically the same thing.
Thanks
|
|
|
|
|
Personally, I find data binding to be a real PITA! It always has some limitation which I need to get around, so invariably I just don't use it.
|
|
|
|
|
fmardani wrote: Are these two methods basically the same thing.
Yes and No
If you want to save the data back to the database and use update on the dataadapter, then databinding knows where to pick the values for fields from. If not, and you are doing it manually, there is not much difference.
Shreekar
http://shreekarishere.blogspot.com
|
|
|
|
|
Hey guys.
A little question on transaction best practices:
1. Where do you put your transaction control code? I mean: Do you put it in the code (try catch rollback()), or do you put it in the stored procedure?
2. Do you use transactions for simple insert, delete, update sentences?
Best Regards
Soeren
|
|
|
|
|
Bad Robot wrote: 1. Where do you put your transaction control code? I mean: Do you put it in the code (try catch rollback()), or do you put it in the stored procedure?
Stored Procedure usually, but sometimes I'll need to do several things in sequence so I'll managet the transaction in .NET
Bad Robot wrote: 2. Do you use transactions for simple insert, delete, update sentences?
If it is a simple oneliner then no because SQL Server, by default, will automatically put that in a transaction for me.
|
|
|
|
|
Hello everyone,
I'm looking at building an N-Tier application in .NET and and i'm looking for samples, books or tutorials to get my skills up to scratch. So far the best article i've found is this from MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/buildntierapp.asp[^]
has anyone else more experienced in N-Tier applications read this and has any comments or suggestions on the document?
Also, if anyone knows a good book on the topic or any other websites please post and let me know
Thanks
|
|
|
|
|
hi
I have made an stored procedure but it is not saving records. Can any one point out error in it.
<br />
CREATE PROCEDURE [update__FData]<br />
(@UName [nvarchar],<br />
@FName [nvarchar],<br />
@Given [bigint],<br />
@Pressed [bigint])<br />
<br />
AS UPDATE [TypingTutorDB].[dbo].[_FData] <br />
<br />
SET [Given] = @Given,<br />
[Pressed] = @Pressed <br />
<br />
WHERE <br />
( [UName] = @UName AND<br />
[FName] = @FName)<br />
<br />
GO<br />
Thanks
Syed Shahid Hussain
|
|
|
|
|
Sometimes when I have this problem, it is because I've been sleeping when I created the procedure, and created it in the wrong database. This error usually happens late at night.
Have you been sleeping?
Best regards,
Soeren
|
|
|
|
|
Bad Robot wrote: Sometimes when I have this problem, it is because I've been sleeping when I created the procedure, and created it in the wrong database.
I think most of us have been there at one time or another. My time is usually first thing on a monday morning when I wonder why none of my tables exist in the "master" database, only to realise 5 minutes later that I forgot to switch to the correct database.
|
|
|
|
|
Exactly, same here - I love to peek over people's shoulders to see if they are also doing this - and 4/10 they do it!!!
Shreekar
http://shreekarishere.blogspot.com
|
|
|
|
|
|
The problem is your parameter data types. You have to set a length for nvarchars.
ex: @UName nvarchar(50)
|
|
|
|
|
You don't use a stored procedure like a table. You execute it rather than select from it. the stored procedure itself may return some records (but doesn't have to, some only create or modify data or structure), but the SP is not itself a valid target for the 'FROM' clause of a select statement.
Your SQL is not valid in ay case, as only one FROM would be expected (possibly multiple tables after the "From" )
You're trying to select results from combinations of results...that won't work.
|
|
|
|
|
I want to change following sql statement to using inner join but I dont know how to join on two column on the two table. Thanks for helping.
select *
from Persons A, Banks B
where B.Student_ID = A.Student_ID
AND B.class_NO = A.claa_NO
when I change to the following statement, I get an error on the syntax. Incorrect syntax near the keyword 'ON'.
select *
from Persons A
INNER JOIN B
ON B.Student_ID = A.Student_ID
ON B.class_NO = A.claa_NO
Please kindly help. Thanks
|
|
|
|
|
Try
SELECT *
FROM PERSONS A
INNER JOIN BANK B
ON B.STUDENT_ID = A.STUDENT_ID
AND B.CLASS_NO = A.CLASS_NO
|
|
|
|
|
It works!!! Thank you very much
|
|
|
|
|
You are not defining B as an alias.
|
|
|
|
|
Hi I am having a problem returning a value from a stored procedure...It keeps returning Nothing...here is the stored procedure:
'===============================================
ALTER PROCEDURE dbo.spAddUser(@Name VARCHAR(50),
@LoginName VARCHAR(50),
@LoginPass VARCHAR(50),
@SecLvl INT)
AS
SET NOCOUNT ON
INSERT INTO dbo.tblUser([Name],
LoginName,
LoginPass,
SecLvl)
VALUES(@Name,
@LoginName,
@LoginPass,
@SecLvl)
RETURN @@IDENTITY
'===============================================
And here is the code I am using to call it:
'===============================================
Public Shared Function ExecuteScalarStoredProc(ByVal conStr As String, ByVal procName As String, ByVal procParams As String) As Object
Dim ret As Object
With New SqlClient.SqlConnection(conStr).CreateCommand
.CommandText = "EXEC " & procName & " " & procParams
.Connection.Open()
ret = .ExecuteScalar
.Connection.Close()
End With
Return ret
End Function
'===============================================
Any sugestions?
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
hi there
well I'm not the greatest in these things but I think the problem lies with ur procedure bcz u dont return values from it... I think u should use OUTPUT parameters in this. then atthe time u call the procedure u dont provide any value for those but u receive the value from it after the stored proc is called. u need to chg the definition of ur stored proc and declare an output variable @Identity as
@Identity INT OUT[PUT]
and in the end dont use RETURN use set @Identity = @@Identity
Go ahead and try it out, I'm sure it'll solve ur problem though but do let me know
Imran Akram.
|
|
|
|
|
Thanks...this is what I ended up doing to get it to work:
ALTER PROCEDURE dbo.spAddUser(@Name VARCHAR(50),
@LoginName VARCHAR(50),
@LoginPass VARCHAR(50),
@SecLvl INT)
AS
SET NOCOUNT ON
INSERT INTO dbo.tblUser([Name],
LoginName,
LoginPass,
SecLvl)
VALUES(@Name,
@LoginName,
@LoginPass,
@SecLvl)
SELECT IDENT_CURRENT('tblUser')
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
|
I think my brain fell on the flore for a few minutes LOL, thanks for the help!
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
I want to do a query by Select Statement on date BUT
the problem that I want to make this query at 5 days before the date in the table.
For Ex,
I have date 6-1-2006 {with format(dd-MM-yyyy)} THEN,
I want when the query works give me a message before 5 days from this date, THAT MEANS
the query will give me the message at 1-1-2006.
I realy wanna do that,
and maney thanks for help...........
soly
|
|
|
|
|
well I dontknow exactly what ur trying to do but
think abt using this
now()// the function for todays date
if now()+5 = <the date="" from="" database="">print (or whatever) "hi there"
|
|
|
|
|
If you tell us what this is being used for then it might help with the answer. I can think of 2 or 3 ways, but they all have limitations which are acceptable in different scenarios.
|
|
|
|