Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with connection string #7

Open
GusBeare opened this issue Apr 24, 2014 · 2 comments
Open

problem with connection string #7

GusBeare opened this issue Apr 24, 2014 · 2 comments

Comments

@GusBeare
Copy link

I have the following code:

 using (var context = new DataContext("SiteSQLServer",Transaction.Begin))
            {
                var job = new DataObject<omv_JobSeekerReferences>();
                int cntr = 1;
                foreach (var item in ViewState)
                {
                    omv_JobSeekerReferences r = (omv_JobSeekerReferences) ViewState["item_" + cntr];

                    var newRefRow = new omv_JobSeekerReferences { UserId = r.UserId,Company = r.Company, FromDate = r.FromDate, ToDate = r.ToDate };
                    job.Insert(newRefRow); // add the new row to the table
                    cntr++; 
                }
            }

It blows on job.Insert complaining that it can't find the connection string "Default".
Am I doing something wrong? It works fine if I add a default connection string and the row is inserted.

@GusBeare
Copy link
Author

I thought this might fix it:

  using (var context = new DataContext("SiteSQLServer", Transaction.Begin))
                    {
                        job.Insert(newRefRow); 
                    }

But same error.

@GusBeare
Copy link
Author

Never mind:

  job.Insert(newRefRow,context); 

pass the context into the insert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant