Connecting to a database through a webservice
Could someone please help me to connect to a database through a webservice in c#.
I currently have,
- The webconfig with the connection string listed.
- A dbml file, which is referencing 1 table in the database I wish to query.
- The asmx file with all my methods. These are all currently functioning, but I now wish to add some additional web metho开发者_JS百科ds to query the database.
Could someone please help me out.
Thanks
Since you mention you have a DBML file, I'm assuming your'e using Linq-to-SQL. ScottGu has some great starter tutorials on using the technology. Here is one of them:
http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
Bottom line at the very basic level you're DBML has a bunch of code behind including the DataContext classes that you run your queries against, using something like:
DataClasses1DataContext dc = new DataClasses1Datacontext();
var q = from table in dc.SomeTable
select table;
Again the link above has some really good examples of how to use Linq-to-SQL.
精彩评论