protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection badersql = new SqlConnection("server = SQLSERVER; uid = sa; pwd = 123; database = webpage");
badersql.Open();
SqlCommand insert_user= new SqlCommand("insert into webpage.dbo.users (username,password,firstname,lastname,address,country,city,phonenumber,gender,email) VALUES (' bader','123','beno','venp','33','pal','d',''1234','male','[email protected]')");
badersql.Close();
}
私はbutton1
をクリックしたときにレコードを挿入しようとしていますが、その私はMSGは SQL Serverの、Visual StudioのINSERTレコードの接続の問題
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)
マイフル
を言ってポップアップすることを試みるたびに思えますサーバー名は、私のデータベース名がwebpage
私のテーブル名が左ペインのメニューでサーバー名それとして「dbo.users」であるBADER-VAIO \ SQLEXPRESS
です。
私は、WebのVisual Studio 2010 ExpressとSQL Server 2010のExpressの
に任意の提案をしてください使用していますか?
問題は、すべてのサーバー名を追加することができません。なぜなら、それを処理してエラーとしてマークするバックスラッシュがあるからです。どうすればいいですか? – Bader
@Bader VBがエラーとみなすコードとエラーメッセージの内容を投稿できます –
@Bader実際に投稿したコードはC#コードなので、Visual Basicに問題があると言う理由がわかりません。また、C#の場合、文字列の前に@を使用して接続文字列をエスケープすることができます。私はサンプルコードを更新しました。 –