Open GoogleCodeExporter opened 9 years ago
[deleted comment]
I tried use "DbMetal.exe --namespace=test --code=sqlite.cs --provider=Sqlite
--conn="data source=testing.sqlite"" to gen a sqlite.cs, but when i run it,got
error
in "public Main(string connectionString): base(connectionString)" ==> "Unable to
load the `DbLinq.SqlServer.dll' DbLinq vendor within assembly `SqlServer'.
Parameter
name: connectionString"
when i add DbLinq.SqlServer.dll to references, will got another error "A
network-related or instance-specific error occurred while establishing a
connection
to SQL Server. The server was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured to allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not open a
connection
to SQL Server)" on DatabaseConnection's "_connection.Open();"(line: 59).
Original comment by alantang...@gmail.com
on 19 Mar 2010 at 9:38
I'm...confused.
The first command (`DbMetal /dbml:Test.dbml ...`) creates a .dbml file. You
then
mention that VS2008 reports an error when loading this file, and that the 4
errors
are in Test.designer.cs.
I'm assuming that you just added the Test.dbml file to your project.
You can't do this, as .dbml files will be processed with the .NET SqlMetal.exe
tool,
not DbMetal, and thus will not have the appropriate DbLinq references.
For example, when I add the DbMetal-generated Test.dbml file, there are no
'using'
statements within Test.designer.cs for DbLinq.Data.Linq, and e.g.
Main.JobsTable is
of type 'System.Data.Linq.Table<JobsTable>'. This won't work.
You need to use DbMetal to generate your Test.designer.cs file.
Comment #2 implies that you figured this out (as you mention that you can run
it,
implying that it built w/o error).
The problem you're hitting in Comment #2 is answered at:
http://code.google.com/p/dblinq2007/wiki/Installation#at_Runtime
Specifically, if you're creating your DataContext using only the connection
string,
you need to provide BOTH DbLinqProvider AND DbLinqConnectionType key/value
pairs in
the connection string; otherwise DbLinq will assume you want to use SQL
Server(hence
the "Unable to load DbLinq.SqlServer" message).
You will also need to copy DbLinq.Sqlite.dll along with DbLinq.dll in order for
your
program to run.
Does this allow things to work for you?
Original comment by jonmpr...@gmail.com
on 19 Mar 2010 at 2:29
Oh!!! i understand now,the step is:
1. generate the test.dbml use:>DbMetal.exe --conn="data source=testing.sqlite"
--provider=sqlite --dbml=test.dbml
2. generate the code file test.designer.cs use:>DbMetal.exe --conn="data
source=testing.sqlite" --provider=sqlite --code=test.designer.cs
3. add the dbml to vs2008.
4. copy the test.designer.cs code replace vs2008's code.
5. the make the instance use SqliteDataContext sqliteDC = new
SqliteDataContext(new
SQLiteConnection("Data Source=testing.sqlite"))
i success to insert a record to sqlite now, thank you very much ^_^
Original comment by alantang...@gmail.com
on 19 Mar 2010 at 3:51
Step 1 isn't necessary.
Alternatively, if you want/need a .dbml file, then you can alter Step 2 to be:
DbMetal /code:Test.designer.cs test.dbml
If you skip step 1, then step 3 isn't necessary (again, depending on whether
you
actually want/need a .dbml file).
That said, it looks like things are working for you. Closing.
Original comment by jonmpr...@gmail.com
on 19 Mar 2010 at 5:08
i see. because i read a book talking about linq to sql the easy way is create a
dbml
file, so i don't really understand what i need... until i see your comment 5,
use
dbmetal generate code = dbml's code behide.
Many thanks ^_^
Original comment by alantang...@gmail.com
on 19 Mar 2010 at 5:15
Any feedback on
http://code.google.com/p/dblinq2007/wiki/VisualStudioAndDbmlFiles
would be appreciated.
Thanks!
Original comment by jonmpr...@gmail.com
on 23 Mar 2010 at 6:50
Original issue reported on code.google.com by
alantang...@gmail.com
on 19 Mar 2010 at 7:52Attachments: