如何在程序段中调用已从数据库中选择出的字段?

yueeryaya 2003-09-12 11:57:50
我在程序前选出一个字段,这个字段中只有一个值
select docurl from f_bilateral
紧接着我做了一个跳转,跳转到另一个页面,
response.Redirect( "../../data/sbxycn/docurl")
docurl中是一个文件名,可上面的语句没有把docurl的值读出来,
这是为什么?跳转这句应如何写?
求教高手!
...全文
45 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
LineCorner 2003-09-17
  • 打赏
  • 举报
回复
response.redirect("../../data/sbxycn/" & docurl)
dongbeiren 2003-09-17
  • 打赏
  • 举报
回复
同意楼上:
dim docurl as string
docurl=ds.Tables("f_bilateral").Rows(0)("docurl")

response.redirect("../../data/sbxycn/" & docurl & ")"
sqhua 2003-09-12
  • 打赏
  • 举报
回复
>>docurl是个字段名,楼上两位的方法好像是用在变量上,还是不行

{ds.Tables("f_bilateral").Rows(0)("docurl")}
这样不就得到该变量了?
acewang 2003-09-12
  • 打赏
  • 举报
回复
if doc(0).ToString() = "" then
response.Redirect("../../data/sbxycn/docurl")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
这是个常量,不会读成中文

elseif doc(0).ToString() <> "" then
response.Redirect("sbxydoc.aspx?id="&id)
else

end if

还有你的代码里面问题多多,该优化一下
acewang 2003-09-12
  • 打赏
  • 举报
回复
docur1=你从数据库读出的值;
Response.Redirect("../../data/sbxycn/"+docurl + ")"
yueeryaya 2003-09-12
  • 打赏
  • 举报
回复
在求高手!很急,加分。
yueeryaya 2003-09-12
  • 打赏
  • 举报
回复
还是不行,我把程序贴上了,麻烦高手看看!

<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)

Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter

Dim SelectCmd As String = "select docurl,doc from f_bilateral where id=@Id"

Dim id = Trim(Request.QueryString("id"))


MyConnection = New SqlConnection("server=(local);database=tbtsps;Trusted_Connection=yes")
MyCommand = New SqlDataAdapter(SelectCmd, MyConnection)

MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@Id", SqlDbType.NVarChar, 20))
MyCommand.SelectCommand.Parameters("@Id").Value = Request.QueryString("id")


DS = new DataSet()
MyCommand.Fill(ds, "f_bilateral")


DataBind()

dim doc() = {ds.Tables("f_bilateral").Rows(0)("doc")}

response.write(doc.ToString())


if doc(0).ToString() = "" then
response.Redirect("../../data/sbxycn/docurl")

elseif doc(0).ToString() <> "" then
response.Redirect("sbxydoc.aspx?id="&id)
else

end if
End Sub

</script>
sqhua 2003-09-12
  • 打赏
  • 举报
回复
哈,你要注意变量的写法
设 docurl 是 string 型
response.redirect("../../data/sbxycn/" + docurl + ")"
yueeryaya 2003-09-12
  • 打赏
  • 举报
回复
docurl是个字段名,楼上两位的方法好像是用在变量上,还是不行
在求高手!
cnhgj 2003-09-12
  • 打赏
  • 举报
回复
response.redirect("../../data/sbxycn/" & docurl)
dongbeiren 2003-09-12
  • 打赏
  • 举报
回复
response.redirect("../../data/sbxycn/" & docurl & ")"

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧