Jump to content
Xtreme .Net Talk

Robby

Moderators
  • Posts

    3848
  • Joined

  • Last visited

Everything posted by Robby

  1. Note that all variables must be surrounded by the & and " The only time you should also use the single quote as I did in the above sample IS when it's a string (both text box or a string variable) If it is a numeric field then you would do something like this... dim intValue as integer = 12 ("Select * from TABLE_NAME where NAME = '" & txtName.text & "' AND SomeNumberField = " & intValue , connectionString)
  2. I tested it and it works, I used almost the same method, here's the complete code.... 'ASPX code..... <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="TestImageFromDatabaseSQL.WebForm1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR"> <meta content="Visual Basic 7.0" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder></form> </body> </HTML> 'ASP code Imports System.Data.SqlClient Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder Protected WithEvents Button1 As New System.Web.UI.WebControls.Button() #Region " Web Form Designer Generated Code " <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try PlaceHolder1.Controls.Add(Button1) Button1.Text = "Display Image" Dim nid As Integer = Convert.ToInt32(Request.QueryString("id")) Dim con As New SqlConnection("server=127.0.0.1;Trusted_Connection=yes;database=NorthWind") Dim cmd As New SqlClient.SqlCommand("SELECT Image FROM Images WHERE ID = " & nid, con) If con.State = ConnectionState.Closed Then con.Open() Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader() If dr.Read() Then Response.ContentType = "image/JPEG" Response.BinaryWrite(CType(dr("Image"), Byte())) End If If Not con.State = ConnectionState.Closed Then con.Close() If Not dr.IsClosed Then dr.Close() If Not cmd Is Nothing Then cmd.Dispose() Catch ex As Exception Response.Write(ex.ToString) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Redirect("http://localhost/TestImageFromDatabaseSQL/WebForm1.aspx?id=6") End Sub End Class
  3. Also, instead of the * you can use all the field names you will need, ie FirstName, LastName, Phone, Address ("Select * from TABLE_NAME where NAME = '" & txtName.text & "' AND ADDRESS = '" & txtAddress.text & "'", connectionString)
  4. In case you want to use ADOX , here's a sample from our own Thinker. http://www.visualbasicforum.com/showthread.php?s=&threadid=20002
  5. Robby

    IIf

    IIF must check both cases, IF only checks the ELSE if the IF is not true. Makes sense? :)
  6. We get many new members daily.
  7. rmatthew, that is not a .NET method, it still uses COM. I guess since I'm not able to provide a solution using .NET, I'll go away now.
  8. I still prefer to call all menu items from toolbar items or vice versa.
  9. I use the above code to allow users to download files from a database, AppendHeader is to give a default name to the file as the user is saving in a SaveAs situation... I don't know how it will act while displaying images as I haven't tried it. (for images)
  10. Restore? do you mean the way it was when it was shipped?
  11. Here's something that I have used in the past, I stripped it down to only what you may need. (I did it for something other than images, but this should work) Private Function GetAttach(ByVal nID As Integer) As Byte() Dim oImage() As Byte 'use nID in the WHERE clause of the SQL statement oImage = CType(yourDataReader.Item("SomeImageField"), Byte()) Return oImage End Function Private Sub GetDownload(ByVal nID As Integer) Try Dim sFile As String = "SomeDefaultName" 'you can use a function to acquire the name Response.Clear() Response.ContentType = "image/JPEG" Response.AppendHeader("Content-Disposition", "filename=" & sFile & ".jpg") Dim oImage() As Byte = GetAttach(nID) Response.BinaryWrite(oImage) Catch Response.Clear() Finally Response.Flush() Response.Close() End Try End Sub
  12. No. your toolbar item can call the menu item like this... mnuFileNew.PerformClick()
  13. You can't make the handles border smaller, if you use the Crtl-Shift to move a control it will be in smaller increments. In Options > Windows Form Designer, there is a Snap To Grid and Grid size, but they don't seem to do much.
  14. I don't know the context of what you're doing, but one common way is to use OleDbCommand with the method .ExecuteNonQuery(). This would use the Delete statement... 'con is your connection string Dim recordsAffected As Integer dim sSql as string = "DELETE ID FROM myTable WHERE ID = " & SomeIntegerVar Dim cmd As OleDbCommand = New OleDbCommand(sSql, con) cmd = New OleDbCommand(sSql, con) recordsAffected = cmd.ExecuteNonQuery()
  15. With the above example I use the Code-Behind method... You can populate an array with the data from a DB and then loop through the array to generate the <td> tags. For a dropdown you can use the same method or if you need to handle events, use a DropDownList (web control) and bind the data using a Dataset.
  16. You can easily use HTML table (tags).... Create and display a Label or Panel, and just do this... Label1.Text = "<table><tr><td>Something</td> .....etc..."
  17. Are you running it in Debug mode? It should point to the exception.
  18. It is quite hard to know which class/mod/object you may have forgotten to rename, but obviously something was not renamed properly. Do you have a backup copy?
  19. Madz, you can copy/paste all the articles you want, but I still cannot agree with this statement... "Windows XP is specifically designed for .NET." And the topic is not close, we haven't heard from Divil yet :)
  20. Banjo, I agree with you on that, it's the same way that most novice folk can't figure out if they need Acrobat Reader or not. But as Volte said, you could explain it to them either with your app or on the download page.
  21. Once again, news to me.
  22. If you're offering your app for download, you can have the exe seperate from the Framework. The user can determine if they need it or not.
  23. Hmm, I thought XP and 2000 had the same core. ??
  24. Try this for files... <......ImageUrl="Sample Pictures\Sunset.jpg"> The images should be in "Sample Pictures" directory, and that Dir should be at the same level as your aspx file.
  25. you can use this in the KeyPress event... If Not e.KeyChar.IsDigit(e.KeyChar) Then and this in the Validating event (in case they paste some text) If Not IsNumeric(textbox1.Text) Then
×
×
  • Create New...