|
Hi
I am tryin to display an image which is stored in a database
i ahve a procedure which will go to the appropiate record in my database and pull the file name from it
it should then take the file name and put it into a prefixed img src tag, which should then take the appropiate file from the imagestore and display to the web page
it all seems to work fine, even when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image
Is there anythin i need to do here? here is my code
<code> Sub getimage(ByVal sender As Object, ByVal e As EventArgs)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; u;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "sp_getImage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim literr As New LiteralControl
Dim param As MySqlParameter
Try
'Creates parameter which will be passed into procedure
param = cmdString.Parameters.Add("?p_id", MySqlDbType.Int32)
'Sets parameter type equal to input
param.Direction = ParameterDirection.Input
'Sets parameter value equal to value held in textbox
param.Value = 4
'Creates parameter to pass into SPROC
param = cmdString.Parameters.Add("?p_image", MySqlDbType.VarChar)
'Sets parameter type to output
cmdString.Parameters("?p_image").Direction = ParameterDirection.Output
connection.Open() 'Opens DB connection
cmdString.ExecuteNonQuery() 'Executes procedure and reads in OUTPUT parameter
connection.Close() 'Closes DB connection
Catch ex As Exception
literr.Text = ex.Message
MsgBox(ex.Message)
End Try
MsgBox(cmdString.Parameters("?p_image").Value)
Dim imageStore As String = cmdString.Parameters("?p_image").Value
MsgBox(imageStore)
imgHolder.ImageUrl = ("c:\test\" & imageStore)
End Sub
<asp:image runat=server ID="imgHolder" Height="282px" Width="488px" BackColor="Red" />
</code>
|
|
|
|
|
boyindie wrote: when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image
You need to set teh ImageUrl to either a relative path from where the webpage is, or else a fully qualified web-address (http://www...etc). It can't just be any folder on your hard drive.
If your page is in the root folder of your website, adn the images in a subfo9lder called "images", you could set
imgHolder.ImageUrl = ("images/" & imageStore)
Your images folder (test) needs to be within your web application.
|
|
|
|
|
my connection code is:
String strConnection;
strConnection = "server=localhost;User ID=sa;Password=sas;database=db";
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
how will i write it in any application configuration file working in windows form,and call it on every page that needs to b connected??
can any body help me??
$h@ma!|@
|
|
|
|
|
i write in the folowing manner
<appsettings>
<add key="sqlserver" value="server=localhost;User
ID=sa;:Dassword=sa;database=db" ;="">
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
First and foremost, this is a VB.Net question (Not ASP.Net since you are using Win Forms) second in your app.config you need a < connectionStrings > < /connectionStrings > section (like below) then add your connection string as I have. The weird thing about your post is you ask how to make it work in the app.config in Windows Forms then you ask how to call it on every "page" taht needs it, Windows Forms dont have "pages". The below example will work in Windows Forms (which is what you asked).
As for the 2nd part of your question, the easiest way to call it is to write a function like below:
'This returns the connection string
Public Shared Function GetConnectionString(ByVal strConnection As String) As String
Dim strReturn As New String("")
'If you have multiple connection strings then you can pass it a connection name otherwise it defaults to your default connection
If Not String.IsNullOrEmpty(strConnection) Then
strReturn = ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
Else
strReturn = ConfigurationManager.ConnectionStrings("MyConnectionName").ConnectionString
End If
Return strReturn
End Function
Then on the form that needs a DB connection call it like this:
Dim oConnection As New SqlConnection(YourClassName.GetConnectionString("MyConnectionName"))
<connectionstrings>
<add name="MyConnectionName">
connectionString="Persist Security Info=False;Data Source=localhost;Initial Catalog=db;Integrated Security=SSPI;Trusted_Connection=TRUE;Application Name=AppName"
providerName="System.Data.SqlClient" />
</add>
</connectionstrings>
If you mis-worded your question and need this for an ASP.Net application (not Windows Forms) reply and let me know and I'll help as much as I can
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
in windows application i want to apply validation checks.i hv trued one for empty textbox
i.e.
if (textBox1.Text == "")
{
MessageBox.Show("Enter phone number", "Error in Input", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBox1.Clear();
this.textBox1.Focus();
return;
}
how to validate numbers and alphabetic characters??
|
|
|
|
|
try ur code on key press event
if(e.keychar>=67 && e.keychar<=90)
{
e.handed=true;
}
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
it is giving error
'System.Windows.Forms.KeyPressEventArgs' does not contain a definition for 'keychar'
software student
|
|
|
|
|
this is the code.
private void keypress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= 67 && e.KeyChar <= 90)
{
e.Handled = true;
}
}
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
I made a page using CreateUserWizard but I restrict it for Admins only. The problem is when an Admin create an account for the new user, after completing the steps, it automatically change the logged in Admin to the new created account. Is there anyway not to login after creating an account? Except for the Security setup wizard on ASP.NET Configuration.
Thanks!
|
|
|
|
|
what code u r writing ?
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
I'm using Visual Studio 2005 and I'm writing ASP.Net pages. CreateUserWizard is very easy to use but I don't know how to change the settings so that after creating a new User, it will not automatically log-in on the user... Only Admins could create a new user.
|
|
|
|
|
Can you copy over the aspx code here?
<< >>
|
|
|
|
|
I want to do it for Drag & Drop & upload.
i want to drag a file from my desktop & drop on my web page.
Can i getimage path,image which i dropped.
it will be a dynamic file may be some image, text file or anything.
Thanx In Advance.
|
|
|
|
|
You'll need to embedd an activeX or .NET control into your page in order to offer this functionality, you can't do it otherwise.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Thank you for your reply.
I was not think about window application. I want to Drag file from client's machine (e.g. Desktop) and Drop it on the web page. and upload it. Please try the code below in html file
http://www.codingforums.com/showthread.php?t=36896
I want same as above but I want to see all dragged images on web page in thumbnail format and the upload.
Thanks in advance.
|
|
|
|
|
hi
I am using asp.net 1.0.
My problem is, button click event firing two times wen i click one it.
how i solve this issue??
All I ever wanted is what others have.... CrazySanker
|
|
|
|
|
A button event generates a postback. There is no way you're getting two click events for one click, there's something wrong in your code. Try posting it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hello vipin,
I think the problem has arised due to the HTML design so plz check ur design. and also bcoz of the events that r fired when the page is created like initalze component(),page load,rendering... etc
ok try like that u will get byeee
Murali
|
|
|
|
|
Whenever I try to connect to the PUBS.MDF database, a login failed error message will appear.
I defined the connection string in the web.config file under the connectionstrings section like this:
[code]
add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI"
[/code]
And setup the connection in the click event of a button:
[code]
Dim connectionString As String = WebConfigurationManager.ConnectionStrings("Pubs").ConnectionString
Dim myConnection As New SqlConnection(connectionString)
myConnection.Open()
..........
[/code]
And I put the PUBS.MDF file in the same folder as the vb source files.
How do I connect to the database correctly?
|
|
|
|
|
KaKa` wrote: add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI"
This looks for a named instance of SQL Server called SQLEXPRESS, and then tries to find a DB called pubs in there. It sure as hell isn't going to find a file called 'pubs.mdf' ( which is an access database )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
what is the database extension supposed to be?
I downloaded it from the microsoft website and it states that these databases are for sql server 2000.
|
|
|
|
|
hello,can we download a .exe file without entering into a website,is it possible,i think we can do that by using RMI,but 'm not sure
can u pls help me out,as soon as possible...
Regards
shilpa
|
|
|
|
|
Not sure exactly what you mean - for a client to download a program, they need to request it from a web page, or connect to a site via an FTP program. You can't download a program without a program on the client end attempting the download, via HTTP or FTP, or via a web service call ( which is HTTP anyhow )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|