表单错误中的问题找不到网络路径 [英] problem in form error The network path was not found

查看:98
本文介绍了表单错误中的问题找不到网络路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这是我的表格:

http://payam-hayati.com



这个表格在本地真实但在主机中假。



错误:

'/'应用程序中的服务器错误。



找不到网络路径



描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.ComponentModel.Win32Exception:找不到网络路径。



这是我的查询:

hi it's my form :
http://payam-hayati.com

this form in local true but in the host false.

Error :
Server Error in '/' Application.

The network path was not found

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The network path was not found.

this is my Query :

sqlserver sqls = new sqlserver(".", "Contact");
        sqls.update("insert into Table_1 values('" + fullname.Text + "','" + email.Text + "','" + description.Text + "')");
        Response.Write("ارسال با موفقیت انجام شد");
        fullname.Text = "";
        email.Text = "";
        description.Text = "";



和我的班级:


and this my class :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;


namespace sql
{
  public  class sqlserver
    {
        SqlConnection con;
        SqlDataAdapter da ;
        SqlCommand sc;
       

        public sqlserver(string server,string dbname)
        {
            con = new SqlConnection("Data Source=" + server + ";Initial Catalog=" + dbname + ";Integrated Security=True");
            da = new SqlDataAdapter();
            sc = new SqlCommand();
            da.SelectCommand = new SqlCommand();
            da.SelectCommand.Connection = con;
            sc.Connection = con;
        }
        ~sqlserver()
        {
            con.Close();
        }
        
        public DataTable select(string str_q)
        {
            DataTable temp = new DataTable();
            da.SelectCommand.CommandText = str_q;
            con.Open();
            da.Fill(temp);
            con.Close();
            return temp;
        }
        public int update(string str_q)
        {
            int result;
            sc.CommandText = str_q;
            con.Open();
            result = sc.ExecuteNonQuery();
            con.Close();
            return result;
        }
		
		 public int update(string str_q,object image)
		 {
		     int result;
			 sc.CommandText = str_q.Replace("**","@picture");
			 sc.Parameters.Add("@picture",image);
			 con.Open();
			 result=sc.ExecuteNonQuery();
			 con.Close();
			 return result;
		 }
        

    }
   
}

推荐答案

正如Wes所说,错误解释了。

所以开始寻找 为什么 你得到它。

并且该代码只有一个部分使用网络地址元素:

As Wes says, the error explains itself.
So start looking for why you are getting it.
And that code only has one part that uses a "network address" element:
con = new SqlConnection("Data Source=" + server + ";Initial Catalog=" + dbname + ";Integrated Security=True");





我首先查看服务器中的内容变量 - 我不认为列出的实例存在...



为了你自己,不要做那样的事情!不要连接字符串以构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。请改用参数化查询。



I'd start by looking at what is in your server variable - I don;t think the listed instance exists...

And for your own sake, don't do things like that! Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.


这篇关于表单错误中的问题找不到网络路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆