Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am working in sql .he show me this erorr.if som one know about this please tell me?
Incorrect syntax near '.'.
the code is this....
C#
string query = "SELECT  dbo.chektable.image" + "FROM   dbo.chektable " + " WHERE ( dbo.chektable.checkid=" + checkbox.Text + ")";
                if(con.State==ConnectionState.Closed)
                    con.Open();
            SqlCommand re=new SqlCommand(query,con);
            string str=Convert.ToString(re.ExecuteScalar());
            pictureBox1.Image= Image.FromFile(str);// mage=image.fr fromfile(str);
Posted
Updated 8-Jun-10 3:48am
v2
Comments
[no name] 5-Jan-16 1:54am    
Hi,
I am working with SQL Server 2008 R2 show me this erorr.if som one know about this please tell me?
Incorrect syntax near ','.
using System;
using System.Collections.Generic;
using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Data.SqlClient;
using System.Data.Sql;
using System.ComponentModel;
using System.Drawing;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtCaptcha.Text = "";
FillCapctha();
}
}
void FillCapctha()
{
try
{
Random random = new Random();
string combination = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder captcha = new StringBuilder();
for (int i = 0; i < 6; i++)
captcha.Append(combination[random.Next(combination.Length)]);
Session["captcha"] = captcha.ToString();
imgCaptcha.ImageUrl = "GenerateCaptcha.aspx?" + DateTime.Now.Ticks.ToString();
}
catch
{

throw;
}

}
protected void btnRefresh_Click(object sender, EventArgs e)
{
refresh();
txtCaptcha.Text = "";
FillCapctha();


lbl.Text = "";


}
public void refresh()
{

txtName.Text = "";

txtEmailId.Text = "";

txtMobileNo.Text = "";

drpdnState.Text = "";

drpdnCity.Text = "";


txtCaptcha.Text = "";


}
protected void btnSendRep_Click(object sender, EventArgs e)
{
if (Session["captcha"].ToString() == txtCaptcha.Text)
{
SqlConnection con=new SqlConnection();
con.ConnectionString ="Data Source=WIN-Q3FHUVKHP7O\\SQLEXPRESS;Initial Catalog=Demat;Integrated Security=True";
con.Open();
SqlCommand cmd = new SqlCommand("insert into DematUsers(Name,Mobile,Email,State,City,Captcha,LoginTime) values('" + txtName.Text + "','" + txtMobileNo.Text + "','" + txtEmailId.Text + "','" + drpdnState.Text + "','" + drpdnCity.Text + "',,'" + txtCaptcha.Text + "''" + dt12.Text + "')", con);
cmd.CommandType = CommandType.Text;
try

{



cmd.ExecuteNonQuery();

lbl.Text = "Data Inserted";

con.Close();




refresh();



}
catch (Exception ex)

{

lbl.Text = ex.Message;

}

}
else{

Response.Write("<script>alert('Captcha Code Invalid!! ')</script>");
FillCapctha();
}

}
}

Apart from this code being a sackable offence where I work, you've not put your string in quotes.
 
Share this answer
 
alemba wrote:
SELECT dbo.chektable.image" + "FROM dbo.chektable


There is no space between dbo.chektable.image and FROM

Try:
SQL
string query = "SELECT  dbo.chektable.image FROM  dbo.chektable WHERE dbo.chektable.checkid=" + checkbox.Text;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900