简体   繁体   中英

Not able to access database in WCF web data services

I'm not able to get access to the database(in entity framework). Every time I try this, it shows me this error:

An error occurred while processing this request.

I'm not getting the proper error message here which would help me to understand better.

Also, can I use SqlConnection instead of entity framework in WCF?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AutoSaleClient.ServiceReference;
using System.Data.Services.Client;
namespace AutoSaleClient
{
    public partial class LoginWindow : Form
    {
        private System.Windows.Forms.BindingSource booksBindingSource;
        public LoginWindow()
        {
            InitializeComponent();
        }
                private void button1_Click(object sender, EventArgs e)
        {
            DataServiceContext autoSaleContext = new DataServiceContext(new Uri("http://localhost:3371/AutoSaleDataService.svc/"));
            AutoSaleSystemDbEntities db = new AutoSaleSystemDbEntities(new Uri("http://localhost:3371/AutoSaleDataService.svc/"));
           // db.IgnoreMissingProperties = true;

          //  _dataContext = new JustBooks_P000002Entities(Classes.Utilities.DataServiceAddress);

            this.booksBindingSource.DataSource = new DataServiceCollection<Car>(db.Cars.Expand("CarId"));
            // var q = from r in db.RigisterdUsers select r;
            Console.WriteLine("this is test ",this.booksBindingSource.ToString());

            new MainForm().Show();
            this.Hide();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}

错误

在浏览器中查看时,请检查AutoSaleDataService.svc是否运行正常,是否有任何错误,请删除服务引用并添加新引用并进行检查。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM