<%@ Page Language="VB" clienttarget=uplevel %>
<%@ Import Namespace="System.Data.OLEDB" %>
<%@ Import Namespace="System.Data" %>
<script language="VB" runat="server">
Dim cnString as string ="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.mappath("clientes.mdb") & ";"
Dim myCn as OleDBConnection = New OleDBConnection(cnString)
Sub Enviar_Click(Sender As Object, E As EventArgs)
dim sqlText as string
dim myCmd as OleDBCommand
sqlText = "INSERT INTO usuarios (nome, email) VALUES ('"
sqlText = sqlText & Request("nome") & "','" & Request("email") & "')"
myCn.Open()
myCmd = New OleDBCommand(sqlText,myCn)
MyCmd.ExecuteNonQuery()
With Label1
.Text = "Usuário Cadastrado com Sucesso !!!"
.ForeColor = System.Drawing.Color.DarkBlue
.Font.Bold = True
.Font.Name = "Verdana"
End With
Mycn.Close()
MyCn = Nothing
end Sub
</script>
<body>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
CellPadding=3
CellSpacing="0"
Font-Name="Tahoma"
MaintainState="false"
style="BORDER:1px solid #336699"
/>
<p> </p>
<form runat="server">
<asp:TABLE font-name="TAHOMA" style="BORDER:1px solid #336699" runat="server">
<asp:TableRow >
<asp:TableCell ColumnSpan="2" Text="<b>Inserir um novo usuario</b>" />
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="Digite seu nome" />
<asp:TableCell>
<asp:TextBox id="nome" runat="server"/>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="Digite seu email" />
<asp:TableCell>
<asp:TextBox id=email runat="server" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text=" " />
<asp:TableCell>
<asp:Button
Text="Enviar"
onclick="Enviar_Click"
Font-Name="Tahoma"
runat="server"
/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
<asp:Label id="Label1" runat="server"/>
</body>
</html>
". Hoje, vai saber...
0 comentários:
Postar um comentário