8 个解决方案
#1
insert into 表3(字段1,字段2) select 表1.UserName,表2.GroupName from 表1,表2 where ...
#2
直接在数据库
select 表1.UserName,表2.GroupName where 1=1 into 表3(col1,col2)
select 表1.UserName,表2.GroupName where 1=1 into 表3(col1,col2)
#3
select 表1的UserName from 表1 where 条件..
string 字段1 = UserName
select 表2的GroupName from 表2 where 条件..
string 字段2 = GroupName
insert into 表3 Value(字段1,字段2) ;
string 字段1 = UserName
select 表2的GroupName from 表2 where 条件..
string 字段2 = GroupName
insert into 表3 Value(字段1,字段2) ;
#4
string strCon = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
#5
string strCon = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
#6
嗯 group 是关键字 要加中括号
#7
insert into [GROUPUSER](USERID,GROUPID) select [USER].USERID,[GROUP].GROUPID from [USER],[GROUP]
group user 都是sql的关键字
group user 都是sql的关键字
#8
太爱你了 帮我解决这个问题
#1
insert into 表3(字段1,字段2) select 表1.UserName,表2.GroupName from 表1,表2 where ...
#2
直接在数据库
select 表1.UserName,表2.GroupName where 1=1 into 表3(col1,col2)
select 表1.UserName,表2.GroupName where 1=1 into 表3(col1,col2)
#3
select 表1的UserName from 表1 where 条件..
string 字段1 = UserName
select 表2的GroupName from 表2 where 条件..
string 字段2 = GroupName
insert into 表3 Value(字段1,字段2) ;
string 字段1 = UserName
select 表2的GroupName from 表2 where 条件..
string 字段2 = GroupName
insert into 表3 Value(字段1,字段2) ;
#4
string strCon = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
#5
string strCon = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
SqlConnection con = new SqlConnection(strCon);
con.Open();
string strSql = "select * from[USER] where [LOGONID]='"+txtAD.Text.Trim()+"'";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataReader dr = com.ExecuteReader();
if(dr.Read())
{
string strconn = ConfigurationManager.ConnectionStrings["TPVConnectionString"].ToString();
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
lblName.Text=dr["USERNAME"].ToString();
lblName.Visible = true;
string strSqlInsert = @"insert into [GROUPUSER](USERID,GROUPID) select USER.USERID,GROUP.GROUPID from USER,GROUP
where GROUPNAME='"+ddlGroup.SelectedValue+"',USERNAME='"+lblName.Text+"'";
SqlCommand comm = new SqlCommand(strSqlInsert,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加权限成功!');</script>");
}
else
{
lblName.Text = "不存在此AD!";
lblName.Visible = true;
btnOk.Enabled = false;
}
con.Close();
这个运行后会显示:
关键字 'GROUP' 附近有语法错误。
#6
嗯 group 是关键字 要加中括号
#7
insert into [GROUPUSER](USERID,GROUPID) select [USER].USERID,[GROUP].GROUPID from [USER],[GROUP]
group user 都是sql的关键字
group user 都是sql的关键字
#8
太爱你了 帮我解决这个问题