无法连接到Sql Compact! [英] Cant connect to Sql Compact!
本文介绍了无法连接到Sql Compact!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我正在制作Win Mobile 6专业应用程序,当我单击按钮添加时,应将文本框的详细信息添加到数据库中,但是当我单击按钮时,我总是收到相同的错误路径无效",我尝试将其复制到其他文件夹中DB,但结果是相同的,我创建了新项目和新数据库,尝试使用新项目,但还是相同的...我不知道即时消息在哪里错误,即时消息使用的代码是:
Hello
im making Win Mobile 6 pro aplication and when i click button add should add details from textbox''s to database , but when i click buton im always getting same error "The path is not valid" , i try to copy to other folders my DB but result is same, i make new project and new database to try whit new project but again same ... i dont know where im wrong the code where im using is :
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace SmartDeviceProject1
{
public partial class novart2 : Form
{
public novart2()
{
InitializeComponent();
}
SqlCeConnection cn = new SqlCeConnection("Data Source=C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\SmartDeviceProject1\\Ege.sdf");
SqlCeCommand cmd = new SqlCeCommand();
private void menuItem1_Click(object sender, EventArgs e)
{
novart f = new novart();
f.Show();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
cn.Open();
cmd = new SqlCeCommand ("Insert into Art (mr,group_id,subgroup_id,quantity_on_stock) values('"+txtmr.Text +"','"+txtgr.Text +"','"+txtsubg.Text +"','"+txtqnt.Text +"')", cn);
cmd.ExecuteNonQuery();
MessageBox.Show("Update Successfull to the Database");
cn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
推荐答案
我怀疑这很简单:Windows Mobile设备没有磁盘,因此不支持"C:"作为设备说明符.
我怀疑整个路径"C:\\ Users \\ USER \\ Documents \\ Visual Studio 2008 \\ Projects \\ SmartDeviceProject1 \\ Ege.sdf"在移动设备或移动设备的仿真器上无效.
I suspect it is pretty simple: Windows Mobile devices don''t have disks, so they don''t support "C:" as a device specifier.
I suspect that the whole path "C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\SmartDeviceProject1\\Ege.sdf" is invalid on the mobile device, or on the emulator of the mobile device.
这篇关于无法连接到Sql Compact!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文