| Author: Alwyn 17 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
u can do this
@DomainName VARCHAR(50)
INSERT INTO UserTable(DomainName) Values (@DomainName ) Insert Into InformationTable(DomainName) Values (@DomainName)
So simple.
Regards, Alwyn Duraisingh.M Jesus saves! The rest of us better make backups. My Blog
|
| Author: Nagarajan 17 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
you have to use Transaction for inserting two tables at a time..
Try this SqlTransaction Trans con.open() string str = "insert into tbl1 values('"+ asdfs+"')" string str1 = "insert into tbl2 values('" + dfdsfd +"')"
sqlcommand cmd = new sqlcommand (str,con); cmd.Transaction = Trans cmd.ExecuteNonQuery()
sqlcommand cmd1 = new sqlcommand (str1,con) cmd1.Transaction = Trans cmd1.ExecuteNonQuery()
Trans.commit() con.close()
Regards,
Naresh
Don't Scream for a Change... Become a Change..
Do not forget to Rate the post..
|
| Author: Dharmaraj 17 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi, For inserting the record for the user table
SqlConnection con = new SqlConnection("your connection string"); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText="INSERT INTO userTable(DomainId,DomainName) VALUES('" + did + "' , '" + dname + "') cmd.ExecuteNonQuery(); // The records will get inserted in to the domain table // similarly while inserting the record in the domain table // you can create another command object // you can insert the values in the user table.
Regards, Dharma Editor,Mentor,MVM Try and fail but don't fail and try Me and DNS
|
| Author: Ankur 17 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
use an stored procedure for it rather doing on front end ,it will save your server trip and increase the performance of your site
Regards Ankur
Dont forget to rate it if it help
|
| Author: kumari 17 Nov 2009 | Member Level: Silver | Rating:  Points: 2 |
I used the following code..in vb.net code its working.but the values are added to the Sqlsevercetable i.e usertable Dim cmnd As SqlCeCommand = New SqlCeCommand(sqlstring, MyConnection) cmnd = New SqlCeCommand("insert into UserInformation([UserId],[DomainName]) Values ('" & userrow.UserId & " ', '" & userrow.DomainName & "')", MyConnection) Dim insertdata As Integer = cmnd.ExecuteNonQuery()
|