我正在尝试使用ac#application连接到sqllite数据库.我之前从未使用过SQLLite.
var connectionString = @"data source='C:\TestData\StressData.s3db'";
connection = new SQLiteConnection(connectionString);
connection.Open();
Run Code Online (Sandbox Code Playgroud)
当我尝试打开连接时,我得到以下异常:
System.NotSupportedException: The given path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
谢谢..
缺口
更新:
我按照建议将"数据源"更改为"DataSource".现在我收到一个新错误:
更改此内容后,我收到一个新错误:System.ArgumentException:Data Source不能为空.使用:memory:在System.Data.SQLite.SQLiteConnection.Open()中打开内存数据库
还有什么建议吗?
我是ASP.NET-ville的新手,温柔.
我一直在对ASP.NET设置进行故障排除,其中服务器/数据库值正在发生变化,因此需要更新web.config.
有多个<add name="NameXYZ" connectionString="blah" />实例(多个ASP.NET组件),但其中一些实例与其他实例的标记不同.
我提供了以下内容:
<add name="CONNECTION-B" connectionString="metadata=res://*/ZZZZ.ssdl;provider=System.Data.SqlClient;provider connection string="Data Source=XXX;Initial Catalog=YYY;Persist Security Info=True;User ID=AAA;Password=BBBB;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<add name="CONNECTION-A" connectionString="server=XXX;database=YYY;user id=XXX;password=BBB" />
Run Code Online (Sandbox Code Playgroud)
我在上面使用了替换值,假设两种格式类型:
(ZZZZ是一个以管道分隔的东西列表)
问题如下:
A)我对同义连接字符串术语的假设是否准确?(数据源<=>服务器,数据库<=>初始目录)
B)标记中是否存在语法错误?我查找过的一些MSDN文档可以"互换使用double,single和marks.
我有2个登录页面:Login.aspx-用于客户登录,xlogin.aspx用于管理员登录我刚刚将我的项目上传到服务器并且所有应用程序页面都运行良好但是当我登录admin xlogin.aspx时我正被转发到admin.aspx页面 - 但我收到此错误:
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file …Run Code Online (Sandbox Code Playgroud) 我确定我在某个阶段之前已经完成了这个,但我现在还不清楚怎么做!我的情景:
// This is generated from EDMX
public partial class HOLDbEntities : DbContext
{
public HOLDbEntities()
: base("name=HOLDbEntities")
{
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我希望这个连接字符串很容易更改(我想从HOLDbEntities实现),所以我需要覆盖这个构造函数.
我试过了:
public partial class HOLDbEntities
{
private const string _contextName = "HOLDbEntities";
public static string ContextName { get { return _contextName; } }
public HOLDbEntities()
: base(ContextName)
{
}
}
Run Code Online (Sandbox Code Playgroud)
但这会引发一个错误:
HOLDbEntities已经定义了一个名为"HOLDbEntities"的成员,它具有相同的参数类型.
我可以理解为什么会出现这种错误,但是为了做我想要实现的目标,我将如何阻止构造函数首先自动生成?
我正在学习通过单击按钮从文本框写入数据库.我已经在我的web.config文件中指定了我的NorthWind数据库的连接字符串.但是,我无法访问后面的代码中的连接字符串.
这就是我尝试过的.
protected void buttontb_click(object sender, EventArgs e)
{
System.Configuration.Configuration rootwebconfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/Mohtisham");
System.Configuration.ConnectionStringSettings constring;
constring = rootwebconfig.ConnectionStrings.ConnectionStrings["northwindconnect"];
SqlConnection sql = new SqlConnection(constring);
sql.Open();
SqlCommand comm = new SqlCommand("Insert into categories (categoryName) values ('" + tb_database.Text + "')", sql);
comm.ExecuteNonQuery();
sql.Close();
}
Run Code Online (Sandbox Code Playgroud)
我得到一个工具提示错误
SqlConnection sql = new SqlConnection(constring);
Run Code Online (Sandbox Code Playgroud)
如
System.data.SqlClient.Sqlconnection.Sqlconnection(string)有一些无效的参数.
我想从负载连接字符串web.config中constring
使用Oracle SQL Developer,我可以将/ -character放入用户名并将密码保留为空,然后我就连接了.我在数据库中创建了OP $ MYWINDOWSUSERNAME用户.
编辑:如果我检查操作系统身份验证复选框(清空和禁用用户名+密码),SQL Developer不起作用.此外,首选项 - >数据库 - >高级 - >使用Oracle客户端未经检查,因此我猜想SQL Developer与我的System.Data.OracleClient.OracleConnection问题有什么关系.
但是,当我尝试形成这样的连接字符串时:
string.Format("Data Source={0}; user id=/;password=;Integrated Security=yes", dbName);
Run Code Online (Sandbox Code Playgroud)
我收到ORA-01017:用户名/密码无效:登录被拒绝
同
string.Format("Data Source={0}; user id=/;password=;Integrated Security=no", dbName);
Run Code Online (Sandbox Code Playgroud)
我得到了ORA-01005.
同
string.Format("Data Source={0};Integrated Security=yes", dbName);
Run Code Online (Sandbox Code Playgroud)
我收到ORA-01017:用户名/密码无效:登录被拒绝
同
string.Format("Data Source={0}; user id=/;", dbName);
Run Code Online (Sandbox Code Playgroud)
我得到了ORA-01005
同
string.Format("Data Source={0};User Id=/;Integrated Security=yes;", dbName);
Run Code Online (Sandbox Code Playgroud)
我得到了ORA-01017
当我指定用户名和密码时,我的程序中的OracleConnection和Oracle SQL Developer都工作.
编辑:这适用于
string.Format("Data Source={0};Integrated Security=yes", dbName);
Run Code Online (Sandbox Code Playgroud)
当sqlnet.ora行
SQLNET.AUTHENTICATION_SERVICES= (NTS)
Run Code Online (Sandbox Code Playgroud)
改为
SQLNET.AUTHENTICATION_SERVICES= (NONE)
Run Code Online (Sandbox Code Playgroud)
如果有人写简短的回答发生了什么以及为什么,我很乐意给予他/她赏金.
oracle ado.net connection-string oracleclient system.data.oracleclient
我看过很多帖子都在问类似的问题,但没有一个问题解决了我的问题.
我的设置如下:
127.0.0.1:1433L5000 -> 127.0.0.1:1433当我127.0.0.1,5000在SQL Management Studio中输入服务器名称时,我可以连接到我想要的数据库.
如果相应地调整我的连接字符串并启动我的应用程序,我会得到以下异常:
Type : SqlException
Message : 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)
Source : Core .Net SqlClient Data Provider …Run Code Online (Sandbox Code Playgroud) c# sql-server connection-string database-connection entity-framework-core
这应该非常简单,但我无法使用Windows身份验证为SQL Server 2008的本地副本提供有效的连接字符串.我已经尝试使用数据链接属性工具来创建连接字符串,它没有连接问题,但当我复制粘贴生成的字符串到我的ADODB.Connection对象的ConnectionString属性时,我得到各种有趣和不同的错误.
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);"
Run Code Online (Sandbox Code Playgroud)
Microsoft OLE DB Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
我尝试了各种类似的连接字符串,但我找不到一个可以使用Windows身份验证的连接字符串.有人能指出我正确的方向吗?
谢谢!
我正在通过创建文件连接path <- file("C:/test.txt"),当打印与连接关联的对象时,我可以看到连接的"属性":
> path
description class mode text opened
"C:/test.txt" "file" "r" "text" "closed"
can read can write
"yes" "yes"
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法弄清楚如何实际访问各种属性值
这是我到目前为止所尝试的:
> attributes(path)
$class
[1] "file" "connection"
$conn_id
<pointer: 0x0000004b>
> path$description
Error in path$description : $ operator is invalid for atomic vectors
> path["description"]
[1] NA
> file.info(path)
Error in file.info(path) : invalid filename argument
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
如何从web.config文件中读取4.5 .net框架中的连接字符串的值?
我正在使用system.configuration,我有一个引用和一个using语句,但在此之后唯一要使用的是.ConfigurationSettings.Appsettings.
没有连接字符串设置.
c# ×5
asp.net ×3
web-config ×3
.net ×2
ado.net ×2
database ×2
sql-server ×2
ado ×1
asp-classic ×1
asp.net-mvc ×1
file ×1
metadata ×1
oracle ×1
oracleclient ×1
r ×1
sql ×1
sqlite ×1
vb.net ×1