Click here to Skip to main content
15,898,222 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Server database updation from oracle database in realtime Pin
uspatel14-May-12 22:44
professionaluspatel14-May-12 22:44 
GeneralRe: SQL Server database updation from oracle database in realtime Pin
Mycroft Holmes15-May-12 12:51
professionalMycroft Holmes15-May-12 12:51 
GeneralRe: SQL Server database updation from oracle database in realtime Pin
uspatel15-May-12 19:02
professionaluspatel15-May-12 19:02 
GeneralRe: SQL Server database updation from oracle database in realtime Pin
pmpdesign15-May-12 20:45
pmpdesign15-May-12 20:45 
QuestionSQL Table Description Pin
Kevin Marois14-May-12 12:16
professionalKevin Marois14-May-12 12:16 
AnswerRe: SQL Table Description Pin
R. Giskard Reventlov14-May-12 12:31
R. Giskard Reventlov14-May-12 12:31 
GeneralRe: SQL Table Description Pin
Kevin Marois14-May-12 12:33
professionalKevin Marois14-May-12 12:33 
QuestionxBase question Pin
David Crow14-May-12 10:05
David Crow14-May-12 10:05 
AnswerRe: xBase question Pin
Kevin Marois14-May-12 11:40
professionalKevin Marois14-May-12 11:40 
QuestionRe: xBase question Pin
David Crow14-May-12 17:22
David Crow14-May-12 17:22 
AnswerRe: xBase question Pin
Kevin Marois15-May-12 6:35
professionalKevin Marois15-May-12 6:35 
QuestionRe: xBase question Pin
David Crow15-May-12 6:55
David Crow15-May-12 6:55 
AnswerRe: xBase question Pin
Kevin Marois15-May-12 7:01
professionalKevin Marois15-May-12 7:01 
GeneralRe: xBase question Pin
David Crow15-May-12 7:30
David Crow15-May-12 7:30 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:31
professionalKevin Marois15-May-12 7:31 
GeneralRe: xBase question Pin
David Crow15-May-12 7:37
David Crow15-May-12 7:37 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:44
professionalKevin Marois15-May-12 7:44 
QuestionOracle: Replace single occurrence of a character Pin
Lash2014-May-12 8:21
Lash2014-May-12 8:21 
AnswerRe: Oracle: Replace single occurrence of a character Pin
rana ray15-May-12 0:56
rana ray15-May-12 0:56 
GeneralLinq to Sql Pin
sindhuan14-May-12 1:10
sindhuan14-May-12 1:10 
GeneralRe: Linq to Sql Pin
Kevin Marois14-May-12 11:45
professionalKevin Marois14-May-12 11:45 
sindhuan wrote:
Is this the right way to do??


No, because

dc.users.InsertOnSubmit("us");


won't even compile, because you're trying to insert a string "ur". Your code is expecting an entity of type user. So you want

dc.users.InsertOnSubmit(us);


So, you first want to query the user to get the name, then insert the new row.

using (MyDataContext dc = new MyDataContext())
{
    var userName = (from u in dc.tblUsers
                    where u.Id = someId
                    select u.UserName).FirstOrDefault();


    user us = new user
    {
        Date = DateTime.Now,
        name = userName
    };

    try
    {
        dc.users.InsertOnSubmit(us);
    }
    catch(Exception e)
    {
        // Handle exception here
    }
}


You will have to adjust the data context and table names and column names, but this should get you started.
If it's not broken, fix it until it is


modified 14-May-12 18:00pm.

QuestionDoubt in a piece of code [Transact-SQL database audit]. Pin
vValkir13-May-12 21:54
vValkir13-May-12 21:54 
AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
Mycroft Holmes13-May-12 22:36
professionalMycroft Holmes13-May-12 22:36 
GeneralRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
vValkir13-May-12 22:54
vValkir13-May-12 22:54 
AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
Corporal Agarn14-May-12 4:08
professionalCorporal Agarn14-May-12 4:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.