Hi all,
Can somone advise me what i need to do to eliminate this error msg.
thanks
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'CommandBehavior' is not declared.
<%@ import namespace="System.Data.OleDb"%>
<html>
<head>
<title>connecting to a Database using vb</title></head>
<script runat="server" language="VB">
dim i As Integer
dim filename as string
dim sb as System.Text.StringBuilder
dim cn as OleDbConnection
dim cmd as OleDbCommand
dim dr as OleDbDataReader
Protected WithEvents Button1 as Button
Sub Button1_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
cn = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;"& _
"Data Source=c:\Inetpub\ & _
"Dorknozzle.mdb")
filename="products.csv"
cmd = New OleDbCommand("Select * from Employees", cn)
cmd.Connection.open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
sb= New System.Text.StringBuilder
'for field name
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)& VbCrLf)
End If
next
'for field value
While dr.Read()
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)& VbCrLf)
End if
Next
End while
dr.close()
cn.Close()
Response.ContentType ="Application/x-msexcel"
Response.AddHeader("content-disposition","attachment;filename="""& filename &"""")
Response.Write(sb.ToString)
Response.End()
End Sub
</script>
Can somone advise me what i need to do to eliminate this error msg.
thanks
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'CommandBehavior' is not declared.
<%@ import namespace="System.Data.OleDb"%>
<html>
<head>
<title>connecting to a Database using vb</title></head>
<script runat="server" language="VB">
dim i As Integer
dim filename as string
dim sb as System.Text.StringBuilder
dim cn as OleDbConnection
dim cmd as OleDbCommand
dim dr as OleDbDataReader
Protected WithEvents Button1 as Button
Sub Button1_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
cn = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;"& _
"Data Source=c:\Inetpub\ & _
"Dorknozzle.mdb")
filename="products.csv"
cmd = New OleDbCommand("Select * from Employees", cn)
cmd.Connection.open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
sb= New System.Text.StringBuilder
'for field name
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)& VbCrLf)
End If
next
'for field value
While dr.Read()
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)& VbCrLf)
End if
Next
End while
dr.close()
cn.Close()
Response.ContentType ="Application/x-msexcel"
Response.AddHeader("content-disposition","attachment;filename="""& filename &"""")
Response.Write(sb.ToString)
Response.End()
End Sub
</script>