Responzive google map on all devices - dictionary

I need a google map to have responsiveness for both computer and smartphone. I need to show only Slovak Republic to the edge of any device's width. Currently, I am using lng and lat to determine the center of the country.
My complete javascript:
//<![CDATA[
var customIcons = {
1: {
icon: '/img/map-marker-icon.png'
},
0: {
icon: '/img/map-marker-icon.png'
}
};
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(48.730556, 19.457222),
zoom: 8,
scrollwheel: false,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml2.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// MAX MEETINGS = 10
var num1 = markers[i].getAttribute("num1");
var nazov1 = markers[i].getAttribute("nazov1");
var popis1 = markers[i].getAttribute("popis1");
var foto1 = markers[i].getAttribute("photo1");
var datum1 = markers[i].getAttribute("datum1");
var num2 = markers[i].getAttribute("num2");
var nazov2 = markers[i].getAttribute("nazov2");
var popis2 = markers[i].getAttribute("popis2");
var foto2 = markers[i].getAttribute("photo2");
var datum2 = markers[i].getAttribute("datum2");
var num3 = markers[i].getAttribute("num3");
var nazov3 = markers[i].getAttribute("nazov3");
var popis3 = markers[i].getAttribute("popis3");
var foto3 = markers[i].getAttribute("photo3");
var datum3 = markers[i].getAttribute("datum3");
var num4 = markers[i].getAttribute("num4");
var nazov4 = markers[i].getAttribute("nazov4");
var popis4 = markers[i].getAttribute("popis4");
var foto4 = markers[i].getAttribute("photo4");
var datum4 = markers[i].getAttribute("datum4");
var num5 = markers[i].getAttribute("num5");
var nazov5 = markers[i].getAttribute("nazov5");
var popis5 = markers[i].getAttribute("popis5");
var foto5 = markers[i].getAttribute("photo5");
var datum5 = markers[i].getAttribute("datum5");
var num6 = markers[i].getAttribute("num6");
var nazov6 = markers[i].getAttribute("nazov6");
var popis6 = markers[i].getAttribute("popis6");
var foto6 = markers[i].getAttribute("photo6");
var datum6 = markers[i].getAttribute("datum6");
var num7 = markers[i].getAttribute("num7");
var nazov7 = markers[i].getAttribute("nazov7");
var popis7 = markers[i].getAttribute("popis7");
var foto7 = markers[i].getAttribute("photo7");
var datum7 = markers[i].getAttribute("datum7");
var num8 = markers[i].getAttribute("num8");
var nazov8 = markers[i].getAttribute("nazov8");
var popis8 = markers[i].getAttribute("popis8");
var foto8 = markers[i].getAttribute("photo8");
var datum8 = markers[i].getAttribute("datum8");
var setp = 0;
var idloc = markers[i].getAttribute("idloc");
var mesto = markers[i].getAttribute("mesto");
var lat = markers[i].getAttribute("lat");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
// IF SET PHOTO
if (foto1 == "") { var photo1 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis1 + "' />"; var link1 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num1 + "' title='" + nazov1 + "<br />Datum: " + datum1 + "<br />Popis: " + popis1 + "' class='morephotos'>Zobraziť popis</a>"; } else { var link1 = "<a href='" + foto1 + "' data-lightbox='" + num1 + "' title='" + nazov1 + "<br />Datum: " + datum1 + "<br />Popis: " + popis1 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo1 = "<div class='cover' style='background-image:url(" + foto1 + ");'> </div>"; }
if (foto2 == "") { var photo2 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis2 + "' />"; var link2 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num2 + "' title='" + nazov2 + "<br />Datum: " + datum2 + "<br />Popis: " + popis2 + "' class='morephotos'>Zobraziť popis</a>"; } else { var link2 = "<a href='" + foto2 + "' data-lightbox='" + num2 + "' title='" + nazov2 + "<br />Datum: " + datum2 + "<br />Popis: " + popis2 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo2 = "<div class='cover' style='background-image:url(" + foto2 + ");'> </div>"; }
if (foto3 == "") { var photo3 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis3 + "' />"; var link3 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num3 + "' title='" + nazov3 + "<br />Datum: " + datum3 + "<br />Popis: " + popis3 + "' class='morephotos'>Zobraziť popis</a>"; } else { var link3 = "<a href='" + foto3 + "' data-lightbox='" + num3 + "' title='" + nazov3 + "<br />Datum: " + datum3 + "<br />Popis: " + popis3 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo3 = "<div class='cover' style='background-image:url(" + foto3 + ");'> </div>"; }
if (foto4 == "") { var photo4 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis4 + "' />"; var link4 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num4 + "' title='" + nazov4 + "<br />Datum: " + datum4 + "<br />Popis: " + popis4 + "' class='morephotos'>Zobraziť popis</a>"; } else { var link4 = "<a href='" + foto4 + "' data-lightbox='" + num4 + "' title='" + nazov4 + "<br />Datum: " + datum4 + "<br />Popis: " + popis4 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo4 = "<div class='cover' style='background-image:url(" + foto4 + ");'> </div>"; }
if (foto5 == "") { var photo5 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis5 + "' />"; var link5 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num5 + "' title='" + nazov5 + "<br />Datum: " + datum5 + "<br />Popis: " + popis5 + "' class='morephotos'>Zobraziť popis</a>"; } else { var link5 = "<a href='" + foto5 + "' data-lightbox='" + num5 + "' title='" + nazov5 + "<br />Datum: " + datum5 + "<br />Popis: " + popis5 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo5 = "<div class='cover' style='background-image:url(" + foto5 + ");'> </div>"; }
if (foto6 == "") { var link6 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num6 + "' title='" + nazov6 + "<br />Datum: " + datum6 + "<br />Popis: " + popis6 + "' class='morephotos'>Zobraziť popis</a>"; var photo6 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis6 + "' />"; } else { var link6 = "<a href='" + foto6 + "' data-lightbox='" + num6 + "' title='" + nazov6 + "<br />Datum: " + datum6 + "<br />Popis: " + popis6 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo6 = "<div class='cover' style='background-image:url(" + foto6 + ");'> </div>"; }
if (foto7 == "") { var link7 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num7 + "' title='" + nazov7 + "<br />Datum: " + datum7 + "<br />Popis: " + popis7 + "' class='morephotos'>Zobraziť popis</a>"; var photo7 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis7 + "' />"; } else { var link7 = "<a href='" + foto7 + "' data-lightbox='" + num7 + "' title='" + nazov7 + "<br />Datum: " + datum7 + "<br />Popis: " + popis7 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo7 = "<div class='cover' style='background-image:url(" + foto7 + ");'> </div>"; }
if (foto8 == "") { var link8 = "<a href='/img/nophotobig.jpg' data-lightbox='" + num8 + "' title='" + nazov8 + "<br />Datum: " + datum8 + "<br />Popis: " + popis8 + "' class='morephotos'>Zobraziť popis</a>"; var photo8 = "<img src='/img/nophoto.jpg' border='0' alt='" + popis8 + "' />"; } else { var link8 = "<a href='" + foto8 + "' data-lightbox='" + num8 + "' title='" + nazov8 + "<br />Datum: " + datum8 + "<br />Popis: " + popis8 + "' class='morephotos'>Zobraziť popis+fotky</a>"; var photo8 = "<div class='cover' style='background-image:url(" + foto8 + ");'> </div>"; }
if (datum1 !== null) { var section1 = "<section><br />" + photo1 + " <p>Dňa: <strong>" + datum1 + "</strong><br />" + link1 + "</p><div class='clear'></div></section>"; } else { var section1 = ""; }
if (datum2 !== null) { var section2 = "<section><br />" + photo2 + " <p>Dňa: <strong>" + datum2 + "</strong><br />" + link2 + "</p><div class='clear'></div></section>"; } else { var section2 = ""; }
if (datum3 !== null) { var section3 = "<section><br />" + photo3 + " <p>Dňa: <strong>" + datum3 + "</strong><br />" + link3 + "</p><div class='clear'></div></section>"; } else { var section3 = ""; }
if (datum4 !== null) { var section4 = "<section><br />" + photo4 + " <p>Dňa: <strong>" + datum4 + "</strong><br />" + link4 + "</p><div class='clear'></div></section>"; } else { var section4 = ""; }
if (datum5 !== null) { var section5 = "<section><br />" + photo5 + " <p>Dňa: <strong>" + datum5 + "</strong><br />" + link5 + "</p><div class='clear'></div></section>"; } else { var section5 = ""; }
if (datum6 !== null) { var section6 = "<section><br />" + photo6 + " <p>Dňa: <strong>" + datum6 + "</strong><br />" + link6 + "</p><div class='clear'></div></section>"; } else { var section6 = ""; }
if (datum7 !== null) { var section7 = "<section><br />" + photo7 + " <p>Dňa: <strong>" + datum7 + "</strong><br />" + link7 + "</p><div class='clear'></div></section>"; } else { var section7 = ""; }
if (datum8 !== null) { var section8 = "<section><br />" + photo8 + " <p>Dňa: <strong>" + datum8 + "</strong><br />" + link8 + "</p><div class='clear'></div></section>"; } else { var section8 = ""; }
var html = "<div class='locationwindow'>" + section1 + " " + section2 + " " + section3 + " " + section4 + " " + section5 + " " + section6 + " " + section7 + " " + section8 + "<div class='clear'></div><hr />Miesto stretnutia: <strong> " + mesto + " </strong></div>";
var icon = customIcons[setp] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
google.maps.event.addDomListener(window, 'resize', initialize);
google.maps.event.addDomListener(window, 'load', initialize)
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
My CSS
#map {
margin: 0;
padding: 0;
height: 800px;
z-index:4;
width: 100%;
}

Related

When I am trying to send image from system it is not showing in mail body

This is my code:
{
string To = Server.HtmlEncode(Request.Cookies["userInfo"]["Email"]).ToString();
string name = Server.HtmlEncode(Request.Cookies["userInfo"]["Name"]).ToString();
string Subject = "IQC Non-leather Status";
string email_body = "Item has been checked by QC with the following details.. ";
string sImage = System.Web.HttpContext.Current.Server.MapPath("~/Content/Uploads/image.jpg");
DataTable dtqc = new ifs_ShipmentInfo_DAL().qc_po_info(site, IQC_STORE_SL);
email_body += #"<table>";
if (dtqc.Rows.Count > 0)
This is the mail body:
{
DataRow dr = dtqc.Rows[0];
email_body += "<tr><td>Supplier Name</td><td>:</td><td>" + Convert.ToString(dr["SUPPLIER_NAME"]) + "</td></tr>";
email_body += "<tr><td>PO NO</td><td>:</td><td>" + Convert.ToString(dr["PO_NO"]) + "</td></tr>";
email_body += "<tr><td>Invoice No</td><td>:</td><td>" + Convert.ToString(dr["COMMERCIAL_INV_NO"]) + "</td></tr>";
email_body += "<tr><td>Invoice recvd date</td><td>:</td><td>" + Convert.ToString(dr["DATE_OF_RECEIVING"]) + "</td></tr>";
email_body += "<tr><td>Part No</td><td>:</td><td>" + Convert.ToString(dr["PART_NO"]) + "</td></tr>";
email_body += "<tr><td>Part Description</td><td>:</td><td>" + Convert.ToString(dr["PART_DESC"]) + "</td></tr>";
email_body += "<tr><td>Invoice Qnty</td><td>:</td><td>" + Convert.ToString(dr["INVOICE_QTY"]) + "</td></tr>";
email_body += "<tr><td>Final Result</td><td>:</td><td>" + INSPECTION_RESULT + "</td></tr>";
email_body += "<tr><td>Reason</td><td>:</td><td>" + insRemarks + "</td></tr>"
+ "<tr><td>Inspected Qnty</td><td>:</td><td>" + INSPECTION_QTY + "</td></tr>"
+ "<tr><td>Accepted Qnty</td><td>:</td><td>" + ACCEPTED_QTY + "</td></tr>"
+ "<tr><td>Rejected Qnty</td><td>:</td><td>" + REJECTED_QTY + "</td></tr>"
+ "<tr><td>Fully Rejected Qnty</td><td>:</td><td>" + FINAL_REJECTED_QTY + "</td></tr>"
+ "<tr><td>Inspected By</td><td>:</td><td>" + INSPECTED_BY + "</td></tr>"
Trying to send image like this:
+ "<tr><td>Defective Picture</td><td>:</td><td><img src='" + sImage + "'width='100'height='100'alt='img'style='margin:20px 0px 0px 20px'/></td></tr>";
}
email_body += "</table>";

When inserting data into the database I get an error

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: String or binary data would be truncated.
This is my code
SqlCommand cmd = new SqlCommand("insert into students (S_username,S_password,S_f_name,S_m_name,S_l_name,S_father_name,S_mother_name,S_dob,S_gender,S_cast_id,S_religion,S_father_occu,S_mothers_occu,S_annual_income,S_local_add,S_p_address,S_L_pincode,S_p_pincode,S_L_city,S_p_city,S_L_state,S_p_state,S_department,S_semistor,s_mob_no,s_parents_mob_no,s_email,S_aadhar_no) values ('" + txtuName.Text + "','" + txtpass.Text + "','" + Txtfname.Text + "','" + Txtmname.Text + "', '" + Txtlname.Text + "','" + TxtFthname.Text + "','" + Txtmname.Text + "','" + TextBox2.Text + "','" + DropDownList2.SelectedItem.Value + "', '" + DropDownList.SelectedItem.Value + "','" + txtrel.Text + "','" + Txtfoccu.Text + "','" + Txtmoccu .Text + "','" + DropDownList1.SelectedItem.Value + "','" + Txtlcaladd.Text + "','" + TxtpAdd.Text + "','" + Txtzipcode.Text + "', '" + Txtzipc.Text + "','" + Txtcity.Text + "', '" + Textcity.Text + "', '" + Txtstate.Text + "', '" + Textstate.Text + "', '" + DropDownList3.SelectedItem.Value + "', '" + Txtsem.Text + "','" + Txtmb.Text + "','" + Txtparmb + "','" + TxtEmail.Text + "','" + TxtAdhno.Text + "')", con);
con.Open();
cmd.ExecuteNonQuery();
txtuName.Text = string.Empty;
txtpass.Text = string.Empty;
Txtfname.Text = string.Empty;
Txtmname.Text = string.Empty;
Txtlname.Text = String.Empty;
TxtFthname.Text = String.Empty;
Txtmname.Text = String.Empty;
TextBox2.Text = String.Empty;
DropDownList2.DataTextField = "TextFiled";
DropDownList.DataTextField = "TextFiled";
txtrel.Text = string.Empty;
Txtfoccu.Text = string.Empty;
Txtmoccu.Text = string.Empty;
DropDownList1.DataTextField = "TextValues";
Txtlcaladd.Text = string.Empty;
TxtpAdd.Text = string.Empty;
Txtzipcode.Text = string.Empty;
Txtzipc.Text = string.Empty;
Txtcity.Text = string.Empty;
Textcity.Text = string.Empty;
Txtstate.Text = string.Empty;
Textstate.Text = string.Empty;
DropDownList3.DataTextField = "TextFiled";
Txtsem.Text = string.Empty;
// objnew.lastAppointmentNo = Convert.ToInt32(Request["txtLastAppointmenNo"]);
int s_mob_no = Convert.ToInt32(Request.QueryString.Get("s_mob_no"));
int s_parents_mob_no = Convert.ToInt32(Request.QueryString.Get(" s_parents_mob_no"));
//Txtmb.Text = string.Empty;
// Txtparmb.Text = string.Empty;
TxtEmail.Text = string.Empty;
int S_aadhar_no = Convert.ToInt32(Request.QueryString.Get(" S_aadhar_no"));
con.Close();
Console.WriteLine("Success");
Two things to do here:
Use parameterized queries to avoid SQL injection:
string query = "insert into students (username, ...) VALUES(#uname, ...)";
SqlCommand cmd = new SqlCommand(query, con);
//Passing values to Parameters
cmd.Parameters.AddWithValue("#uname", "Value");
Check the parameter values are in accordance with the columns in your SQL table both datatype and size. I think it is the size which is causing the problem in your case. You are trying to insert data that has a greater length than what you have defined for that column in the SQL table.
use parametrized queries so you avoid SQL Injection attacks
//Replaced Parameters with Value
string query = "insert into students (S_username, ...) VALUES(#username, ...)";
SqlCommand cmd = new SqlCommand(query, con);
//Pass values to Parameters
cmd.Parameters.AddWithValue("#username", "XYZ_Value");
cmd.Parameters.AddWithValue("#...", "$20");

Correct way to pass SqlParameter into SQL native query Asp Core web api

This is my
String tempStr = "'''" + shain.searchAffiliation + "'''";
If I use
String affSetStr = " SET #Affiliation = " + tempStr + " ;"; "
Then pass to queryStr, the query will work without any problem. But this query will have sql injection attack.
Now I pass tempStr variable to
SqlParameter shainParameterSearchName = new SqlParameter("#searchAffiliation", tempStr);
Then my query is return an empty list. What is the right way to pass tempStr to SqlParameter("#searchAffiliation", tempStr);?
String tempStr = "'''" + shain.searchAffiliation + "'''";
SqlParameter shainParameterSearchName = new SqlParameter("#searchAffiliation", tempStr);
shainParamsObj.Add(shainParameterSearchName);
affSetStr = " SET #Affiliation = " + tempStr + " ;";
String queryStr = " " +
"DECLARE #Name VARCHAR(50);" +
"DECLARE #Affiliation VARCHAR(50); " +
searchSetStr +
affSetStr +
"DECLARE #AgeStr INT;" +
"DECLARE #AgeEd INT;" +
"SET #AgeStr = #ageStart;" +
"SET #AgeEd = #ageEnd; " +
"DECLARE #fromIdx INT;" +
"DECLARE #toIdx INT; " +
"SET #fromIdx = #fromIndex; " +
"SET #toIdx = #toIndex; " +
"declare #sqll nvarchar(max) = '" +
"SELECT" +
" * " +
" FROM" +
" ( SELECT" +
" ROW_NUMBER() OVER ( " +
" ORDER BY " + orderStr +
" ) AS RowNum, " +
" S1.INCODE id , " +
" DATEDIFF(DAY,S1.KOM005,GETDATE()) age, " +
" CASE " +
" WHEN DATEDIFF(DAY,S1.KOM035,S1.KOM027) < 0 " +
" THEN DATEDIFF(DAY, S1.KOM035, GETDATE()) " +
" ELSE DATEDIFF(DAY, S1.KOM035, S1.KOM027) " +
" END AS lenghtOfService , " +
" S1.KOM001 employeeCode , " +
" S1.KOM005 dbo , " +
" ISNULL(S1.KOM004,0) gender , " +
" S1.KOM035 enterDate , " +
" S1.KOM027 retireDate , " +
" S2.KOM506 postion , " +
" S2.KOM002 name , " +
" S2.KOM003 furigana , " +
" S2.KOM021 phone , " +
" S2.KOM527 email, " +
" S2.KOM512 postCode , " +
" S2.KOM509 contactPerson ," +
" S2.KOM513 address1 , " +
" S2.KOM514 address2," +
" S2.KOM515 tel1, " +
" S2.KOM507 affiliation, " +
" S2.KOM516 tel2, " +
" ISNULL( '+ dbo.CheckIfColumnExist( 'dbo','RIREKI13','R.KOM001', 'CAST(0 as FLOAT)' ) + ' ,0) CP , " +
" ISNULL( '+ dbo.CheckIfColumnExist( 'dbo','RIREKI13','R.KOM002', 'CAST(0 as FLOAT)' ) + ' ,0) NP, " +
" ISNULL( '+ dbo.CheckIfColumnExist( 'dbo','RIREKI13','R.KOM003', 'CAST(0 as FLOAT)' ) + ' ,0) A, " +
" ISNULL( '+ dbo.CheckIfColumnExist( 'dbo','RIREKI13','R.KOM004', 'CAST(0 as FLOAT)' ) + ' ,0) FC, " +
" ISNULL( '+ dbo.CheckIfColumnExist( 'dbo','RIREKI13','R.KOM005', 'CAST(0 as FLOAT)' ) + ' ,0) AC " +
" FROM " +
" dbo.SHAIN1 as S1 " +
" join " +
" dbo.SHAIN2 as S2 " +
" on S1.INCODE = S2.SHAIN " +
" FULL join " +
" RIREKI13 as R " +
" on R.INCODE = S2.SHAIN " +
ifCase +
" ) AS RowConstrainedResult " +
" " +
" WHERE RowNum >= " +
" ' + CONVERT(VARCHAR(12), #fromIdx) + ' " +
" AND RowNum < " +
" ' + CONVERT(VARCHAR(12), #toIdx) + ' " +
" ORDER BY RowNum " +
"'; " +
" exec sp_executesql #sqll ";
List<Shain> shainList = await _context.Shain.FromSql(queryStr,shainParamsObj.ToArray()).ToListAsync();

What is wrong with filling this datatable in asp.net

I am trying to fill a list from a database. Here is my code:
string cur = dInstructorSelect.SelectedValue.Substring(dInstructorSelect.SelectedValue.IndexOf(" - ") + 3);
SqlCommand cmdInsCourses = new SqlCommand("select * from CourseTable where InstructorID=#cur", con);
cmd.Parameters.AddWithValue("#cur", cur);
SqlDataAdapter da = new SqlDataAdapter(cmdInsCourses);
DataTable dt = new DataTable();
da.Fill(dt);
Here, i declare a string variable cur, which returns 4 as i expect. The problem is, when i debugged, there is an error saying that Must declare the scalar variable "#cur". I cannot see what is problematic here. Can anyone help?
Thanks
Edit: Here is the full code:
SqlConnection con = new SqlConnection();
con.ConnectionString = Userfunctions.GetConnectionString();
int result;
string queryCourseCount = "select count (*) from CourseTable";
SqlCommand countCommand = new SqlCommand(queryCourseCount, con);
con.Open();
int courseCount = 1001 + Convert.ToInt32(countCommand.ExecuteScalar());
string crn = (MyGlobals.currentYear % 100).ToString() + (MyGlobals.currentTerm == "Spring" ? 2 : 1) + courseCount.ToString().Substring(1, 3);
string instructor = dInstructorSelect.SelectedValue.Substring(dInstructorSelect.SelectedValue.IndexOf(" - ")+3);
string subject = dSubject.SelectedValue, courseNumber=tCourse.Text, courseName= tCourseName.Text ;
string courseDescription = tCourseDescription.Text, capacity=tCapacity.Text;
string currentTerm=MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString();
string level=dLevel.SelectedValue, credit=tCredit.Text;
string query1 = "insert into CourseTable(InstructorID,CourseCode,CourseNumber,CourseName,Term, CRN,Level,Credit,Description,Capacity) values(#instructor,#subject,#courseNumber,#courseName,#currentTerm,#crn,#level,#credit,#courseDescription,#capacity)";
SqlCommand cmd = new SqlCommand(query1, con);
cmd.Parameters.AddWithValue("#instructor", instructor);
cmd.Parameters.AddWithValue("#subject", subject);
cmd.Parameters.AddWithValue("#courseNumber", courseNumber);
cmd.Parameters.AddWithValue("#courseName", courseName);
cmd.Parameters.AddWithValue("#currentTerm", currentTerm);
cmd.Parameters.AddWithValue("#crn", crn);
cmd.Parameters.AddWithValue("#level", level);
cmd.Parameters.AddWithValue("#credit", credit);
cmd.Parameters.AddWithValue("#courseDescription", courseDescription);
cmd.Parameters.AddWithValue("#capacity", capacity);
string query2 = "";
string query3 = "";
if (cbPreq1.Checked)
{
query2 = "insert into PrereqTable(CourseCode,CourseNumber,Term,pCourseCode,pCourseNumber) values ('"
+ dSubject.SelectedValue + "'" + "," + "'" + tCourse.Text + "'" + "," + "'" + MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString()
+ "'" + "," + "'" + dPrereq1.SelectedValue.Substring(0, dPrereq1.SelectedValue.Length - 3) + "'" + "," + "'" + dPrereq1.SelectedValue.Substring(dPrereq1.SelectedValue.Length - 3, 3) + "'" + ")";
}
if (cbPreq2.Checked)
{
query3 = "insert into PrereqTable(CourseCode,CourseNumber,Term,pCourseCode,pCourseNumber) values ('"
+ dSubject.SelectedValue + "'" + "," + "'" + tCourse.Text + "'" + "," + "'" + MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString()
+ "'" + "," + "'" + dPrereq2.SelectedValue.Substring(0, dPrereq2.SelectedValue.Length - 3) + "'" + "," + "'" + dPrereq2.SelectedValue.Substring(dPrereq2.SelectedValue.Length - 3, 3) + "'" + ")";
}
string query4="";
if (cbtime1.Checked)
{
query4 = "insert into TimeTable(CourseCode, CourseNumber, Term, StartHour, EndHour, Day) values ('"
+ dSubject.SelectedValue + "'" + "," + "'" + tCourse.Text + "'" + "," + "'" + MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString()
+ "'" + "," + "'" + dHourStart.SelectedValue + "'" + "," + "'" + dHourEnd.SelectedValue + "'" + "," + "'" + dDay.SelectedValue + "'" + ")";
}
string query5 = "";
if (cbtime2.Checked)
{
query5 = "insert into TimeTable(CourseCode, CourseNumber, Term, StartHour, EndHour, Day) values ('"
+ dSubject.SelectedValue + "'" + "," + "'" + tCourse.Text + "'" + "," + "'" + MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString()
+ "'" + "," + "'" + dHourStart2.SelectedValue + "'" + "," + "'" + dHourEnd2.SelectedValue + "'" + "," + "'" + dDay2.SelectedValue + "'" + ")";
}
string query6="";
if (cbtime3.Checked)
{
query6 = "insert into TimeTable(CourseCode, CourseNumber, Term, StartHour, EndHour, Day) values ('"
+ dSubject.SelectedValue + "'" + "," + "'" + tCourse.Text + "'" + "," + "'" + MyGlobals.currentTerm + " " + MyGlobals.currentYear.ToString()
+ "'" + "," + "'" + dHourStart3.SelectedValue + "'" + "," + "'" + dHourEnd3.SelectedValue + "'" + "," + "'" + dDay3.SelectedValue + "'" + ")";
}
SqlCommand cmd1, cmd2, cmd3, cmd4, cmd5, cmd6;
bool correctTime = false;
List<String> timeTable = new List<string>();
List<Course>instCourses = new List<Course>();
string tableName = "InstructorTable";
// String name = "", surname = "", email = "";
// CreateUser(con, tableName, ref name, ref surname, ref email);
// MyGlobals.instructor = new Instructor(Convert.ToInt32(idBox.Text), "Active", email, name, surname, passwordBox.Text);
string cur = dInstructorSelect.SelectedValue.Substring(dInstructorSelect.SelectedValue.IndexOf(" - ") + 3);
SqlCommand cmdInsCourses = new SqlCommand("select * from CourseTable where InstructorID=#cur", con);
cmd.Parameters.AddWithValue("#cur", cur);
SqlDataAdapter da = new SqlDataAdapter(cmdInsCourses);
DataTable dt = new DataTable();
da.Fill(dt);
Note: I know there are some queries that are not parametrized, i will fix them.
Try prefixing your parameter with #:
cmdInsCourses.Parameters.AddWithValue("#cur", cur);
Try adding the scalar variable "#cur" rather than "cur":
cmd.Parameters.AddWithValue("#cur", cur);
Try like this...
SqlCommand cmdInsCourses =
new SqlCommand("select * from CourseTable where InstructorID=#cur", con);
cmdInsCourses.Parameters.Add("cur", SqlDbType.VarChar).Value = cur;
EDIT : The Problem lies that you are adding parameters to cmd, not to cmdInsCourses, I have changed the code, just look into that.

twiiter bootstrap align thumbnails dynamically

i'd like to have the thumbnails aligned dynamically, but how can i do it?
i have the following code:
HTML
<div class="row-fluid">
<ul class="thumbnails">
<uc1:loadUsers runat="server" ID="loadUsers" />
</ul>
</div>
ASP.NET
this is a UserControl
_str is a string which will be added to a literal control which converts this to HTML
_str = "<li class='span3'>"
+ "<div class='thumbnail'>"
+ "<div class='caption'>"
+ "<h3>" + _name + "</h3>"
+ "<ul>"
+ "<li><h5>" + _other + "</h5></li>"
+ "<li><h5>" + _other + "</h5></li>"
+ "<li><h5><img src='" + _imagePath + "'" + _size + " /> " + _other + "</h5></li>"
+ "<br><li>"
+ "<div class='btn-group'><button class='btn btn-info'>Options</button><button class='btn btn-info dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button><ul class='dropdown-menu'>"
+ "<li><a href='users.aspx?delete=" + _id + "'><i class='icon-fire'></i> Delete</a></li>"
+ "<li><a href='users.aspx?edit=" + _id + "'><i class='icon-edit'></i> Edit</a></li>"
+ "</ul></div>"
+ "</li>"
+ "</ul>"
+ "</div>"
+ "</div>"
+ "</li>";
i know that the class='row-fluid' is the responsible for the alignment, how can i use it dinamicly?
The problem was that i was inserting <li> but in HTML i didn't have an <ul>, thats the reason to this to be unformulated dynamically.
So i've inserted <div></div> at the beginning and in the end of the dynamic control.
i solved this easily:
_str = "<div><li class='span3'>"
+ "<div class='thumbnail'>"
+ "<div class='caption'>"
+ "<h3>" + _name + "</h3>"
+ "<ul>"
+ "<li><h5>" + _other + "</h5></li>"
+ "<li><h5>" + _other + "</h5></li>"
+ "<li><h5><img src='" + _imagePath + "'" + _size + " /> " + _other + "</h5></li>"
+ "<br><li>"
+ "<div class='btn-group'><button class='btn btn-info'>Options</button><button class='btn btn-info dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button><ul class='dropdown-menu'>"
+ "<li><a href='users.aspx?delete=" + _id + "'><i class='icon-fire'></i> Delete</a></li>"
+ "<li><a href='users.aspx?edit=" + _id + "'><i class='icon-edit'></i> Edit</a></li>"
+ "</ul></div>"
+ "</li>"
+ "</ul>"
+ "</div>"
+ "</div>"
+ "</li></div>";

Resources