开发者

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,

  1. The webconfig with the connection string listed.
  2. A dbml file, which is referencing 1 table in the database I wish to query.
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜