C# и SQL project exe для форм и кодов
я скачиваю проект на веб-сайте, построенном visaul studio asp.net и еще C#.net и sql server 2005
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Configuration; namespace Server { class Class1 { string constring = Convert.ToString(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand cmd1, cmd2, c, c1, cmd3,cmd7; string id, id1, id2, id3, id4; int eid, eid1, eid2, eid3, eid4; public int idgeneration() { SqlConnection con = new SqlConnection(constring); con.Open(); SqlCommand c1; c1 = new SqlCommand("select max(ID) from Registration", con); id = Convert.ToString(c1.ExecuteScalar()); if (id == "") { eid = 1; } else { eid = Convert.ToInt16(id); eid = eid + 1; } con.Close(); return eid; } public int uploadfileid() { SqlConnection con1 = new SqlConnection(constring); con1.Open(); SqlCommand c1; c1 = new SqlCommand("select max(fileid) from uploadfiles", con1); id1 = Convert.ToString(c1.ExecuteScalar()); if (id1 == "") { eid1 = 1; } else { eid1 = Convert.ToInt16(id1); eid1 = eid1 + 1; } con1.Close(); return eid1; } public int senditems() { SqlConnection con1 = new SqlConnection(constring); con1.Open(); SqlCommand c1; c1 = new SqlCommand("select max(Req_ID) from senditems", con1); id1 = Convert.ToString(c1.ExecuteScalar()); if (id1 == "") { eid1 = 1; } else { eid1 = Convert.ToInt16(id1); eid1 = eid1 + 1; } con1.Close(); return eid1; } public int autoid() { SqlConnection con4 = new SqlConnection(constring); con4.Open(); SqlCommand c5; c5 = new SqlCommand("select max(autid) from usersearch", con4); id2 = Convert.ToString(c5.ExecuteScalar()); if (id2 == "") { eid2 = 1; } else { eid2 = Convert.ToInt16(id2); eid2 = eid2 + 1; } con4.Close(); return eid2; } public void uploadfile(string fid, string finame, byte[] File, string time, string path1,string ext) { SqlConnection con2 = new SqlConnection(constring); con2.Open(); int n = finame.Length; cmd2 = new SqlCommand("insert into uploadfiles values('" + fid + "','" + finame + "',@File,'" + time + "','" + path1 + "','"+ext+"')", con2); cmd2.Parameters.AddWithValue("@File", File); cmd2.ExecuteNonQuery(); con2.Close(); } public void senditems(string reqid, string sendid, string fname, byte[] File, string uname, string userip, string send) { SqlConnection con7 = new SqlConnection(constring); con7.Open(); int n = fname.Length; cmd7 = new SqlCommand("insert into senditems values('" + reqid + "','" + sendid + "','" + fname + "',@File,'" + uname + "','" + userip + "','"+send+"')", con7); cmd7.Parameters.AddWithValue("@File", File); cmd7.ExecuteNonQuery(); con7.Close(); } public void usersearch(string auid, string reqid, string usrid, string unam, string filnm, string dat, string sta) { SqlConnection con3 = new SqlConnection(constring); con3.Open(); cmd3 = new SqlCommand("insert into usersearch values('" + auid + "','" + reqid + "','" + usrid + "','" + unam + "','" + filnm + "','" + dat + "','Key not send')", con3); cmd3.ExecuteNonQuery(); con3.Close(); } public void keymaintain(string aid, string reqid, string usrid, string secretky, string path, string path1) { SqlConnection con4 = new SqlConnection(constring); con4.Open(); cmd1 = new SqlCommand("insert into keymaintenance values('" + aid + "','" + reqid + "','" + usrid + "','" + secretky + "','" + path + "','')", con4); cmd1.ExecuteNonQuery(); con4.Close(); } } }
Что я уже пробовал:
problem on connecting string so please help me how to connect
RickZeeland
Какую базу данных SQL Server вы используете-localDb, Express или standard ?
Какой тип аутентификации вы используете для проверки подлинности базы данных, windows или Sql Server ?
johndevmars
его в SQL, экспресс-выпуск -2008
проверка подлинности Windows