Inserting Pictures In DB - For VB Programmers
Jan 13, 2004
Private conn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub ConnectToDB()
Dim strData As String
'Establish the connection.
Set conn = New ADODB.Connection
Call conn.Open("driver={SQL Server};server=srv_scgbscg_sgbd;uid=tdela;pwd=pas sword;database=Mercure_tst")
'Open the recordset
Set rs = New ADODB.Recordset
'Make sure you don't retrieve any data !!!
Call rs.Open("Select * From Images Where FileName='0'", _
conn, _
adOpenKeyset, _
adLockOptimistic)
Call SaveToDB
Call rs.Close
Call conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub
Private Sub SaveToDB()
Dim bytBLOB() As Byte
Dim strImagePath As String
Dim intNum As Integer
'Save the record
strImagePath = Trim("c:windowsureauMyImage.bmp")
With rs
'Open the picture file
intNum = FreeFile
Open strImagePath For Binary As #intNum
ReDim bytBLOB(FileLen(strImagePath))
'Read data and close file
Get #intNum, , bytBLOB
Close #1
Call .AddNew
.Fields("FileName") = "The image title"
Call .Fields("Picture").AppendChunk(bytBLOB)
Call .Update
End With
End Sub
View 1 Replies
ADVERTISEMENT
Jan 6, 2004
hi ,
I am using ASP.NET with SQL Server. I have a function ABC() which creates,open ,and then dispose sqlserver's connection .
I am using ABC() twice in one .aspx page ,my friend who build this function argued that this function will open only one connection in everypage ,no matter how many times we call function ABC() in a single page ,while i denies .
Please tell me ,because our whole company database acces relies on this single ABC() function.
Thanks in Advance
View 2 Replies
View Related
Sep 14, 2006
Dear All Software Developers,I am a hardcore programmer who treat programming as a hobby. Recently,I have just created a website (http://www.sqlref.com) to share myknowledge and programming experience and to record down any new tricksthat I learned. This website started with SQL info. becaue I think SQLis the most basic but must know thing for all software developers.Eventually, I will make this website covers other topics such as .NET,SQL Server, Oracle, DB2 and so on. I will update it everyday.I think all developers should be able to access the SQL reference /Guide at any time, any place. Thus, I created this website for anybodywho need reference on SQL. While you are doing programming and stuckwith the SQL syntax, just open you web browser and typehttp://www.sqlref.comto look for you answer. I guess sqlref.com is easy enought to remember.No registration is required because I am not selling or marketinganything. Just a website for programmers to refer.I hope the website is useful to you all.Enjoy!Warmest Regards,Allen
View 2 Replies
View Related
Dec 5, 2007
Hi, I'm working in a web project.
In our lab, all the PCs are installed with SQL Server Management Studio, and the codes of the site are left by the previous batch of programmers.
Here is briefly how our web works, the web will call the sql server providing a username (userA) and password (aaaaaa) to log into the database, then the web can connect to the database to do various functions like select, insert, update and delete.
Currently anyone can go to thier SQL Server Management Studio on thier PC to edit various things like names and columns of tables by logging in as userA.
But, we now only want a small number of users to have the ability to change things in the database. What are some ways we can do that?
Something that I've thought of is that only allow userA to log in and do functions like select, insert, update and delete and do not have the ability to edit things like names and columns of tables. Have a userB with password only known to me that can have full control of the database which I have done.
View 2 Replies
View Related
Jul 20, 2005
Does anyone have any basic, simple scripts of sp's that I can give mycomputer operators to use to monitor for serious conditions on our sqlservers? We are new in the ms-sql arena, a small shop and we cantreally purchase any tools to monitor these servers, but we need somebasic checks that we can use to make sure a server is performing in areasonable fashion, no blocks, cpu<xx%, memory not pegged, IO working,etc...and we need to be able to do this without bugging ourprogrammers every time we are wondering why things are slowwnig down.We are a split shop between as400s and sql servers, and our operationsstaff has no problem performing this type of duty on the 400s. I thinksince the sql servers are so easy to deploy into production, the ideaof how to monitor these things health got lost in the shuffle andallowing the programmers to do it just serves to destabilize ourenvironment.Please help! Our shop has turned to chaos since we went live withMSSQL centric applications and everytime one programmer "resolves anissue" some other programmers application starts to act up.
View 6 Replies
View Related
Sep 13, 2006
Is it better to have users that upload pictures have them saved to SQL server or to a folder? I have a site where users enter things that they own (and each item has a unique id) and now I would like to add the functionality to add a picture. I am sure I should use the fileUpload control, but should this save to a folder created for each user or to the SQL record itself? Or possibly a separate SQL table just for pictures?Thanks for the help.
View 1 Replies
View Related
Oct 22, 2007
I am building this project and for all the data i put in to the DB Title,Author, etc.... ineed to also add a picture of the book. I terms on space what is the best way to do this? In the DB? Or ref a folder? If so does anyone have sample code for each.
ThanksMike
View 23 Replies
View Related
Mar 2, 2001
I'm trying to efficiently scan images into the database and then call them up/display them on an ASP page. Does anyone know the best way to do this?
View 2 Replies
View Related
Jun 3, 2005
Hi,
How do I go about inserting a picture/image into a column in a MSSQL table ???
Also of what type must the columns be ?
Many thanks
View 6 Replies
View Related
Sep 13, 2007
Hy, could someone help me in this:In design mode, i want to put pictures in database. I made column namedpics, and its type as image. How can I put pictures or some address of thesepictures in that column, or i maybe need to put pictures in Add_Data folderand make reference from there, or what I need to do?could someone explain me that process of putting at least one picture indatabase, I'm using Microsoft SQL Server 2005thanks everyone
View 4 Replies
View Related
Aug 15, 2004
how can i save pictures in sql server and retreive them
View 1 Replies
View Related
Aug 18, 2004
I'm constructing an image gallery for my site and was wondering how to store the pictures in the database? Would the best way to do it, by storing the link instead of the image in the database?
How would I use the insert and select with it? :confused:
View 1 Replies
View Related
Nov 7, 2007
I have a database called ‘Objects’ which has many field. One of its fields is called ‘Image’ and has a data type image.
I want to add pictures to each one of my records offline, is this possible? i.e. by copying the address from my C drive such as C:Documents and SettingsfseyedarabiMy DocumentsMy Pictures
View 1 Replies
View Related
Apr 17, 2001
Hey all,
Just starting to investigate this. I need to store digital pictures in my database for use in claims and disputes. I have played a bit with the image datatype but notice that one picture takes up 1Mb as a TIFF and 3Mb as a JPEG. Does anybody work with this stuff and if you do what is the best picture format to use in regards to keeping clarity but minimizing size used in the db. Is there any load conversion routines that would shrink the size of the file.
Any suggestions or comments on this topic are appreciated.
Thx. Kelsey
View 1 Replies
View Related
Apr 17, 2001
Hey all,
Just starting to investigate this. I need to store digital pictures in my database for use in claims and disputes. I have played a bit with the image datatype but notice that one picture takes up 1Mb as a TIFF and 3Mb as a JPEG. Does anybody work with this stuff and if you do what is the best picture format to use in regards to keeping clarity but minimizing size used in the db. Is there any load conversion routines that would shrink the size of the file.
Any suggestions or comments on this topic are appreciated.
Thx. Kelsey
View 1 Replies
View Related
Apr 3, 2006
Dear All,
I am new to dot not. I'm using vbdot net 2003 with crystal reports that bundled with vs2003 for creating catalogues for our company. We have furniture pictures in access db. In design time I have added picture field to the crystal reports and ticked the cangrow property so the picture can fit into its true aspect ratio. but some pictures grow into full page of the report. unticking 'cangrow' property also makes trouble as the picture does't streches well. I want 6 pictures to appear in each page by 2 column wise(how to add 2 columns in a report?). We want to automate printing catalogues of chosen furnitures by our customers. I'm struck with this problem for past few days.
can anyone help with sample code please?
Thanks a lot in advance
View 2 Replies
View Related
Jan 22, 2007
Hi all,
I am using ASP.NET 2003 with SQL Server as database.
I have a database of a book store with BookPicture, Author, Title, and Description of the Book.
Now when the user searchers for a book with a keyword, how can I display the results which should show:
1. The picture of the book, 2. The at it right, Title of Book, 3. The author,4. The descritionThen the image of "Add to cart"
Each search result must be separated by a box like the cell of a table.
Is it possible to be done?
Thanking you in advance
Tomy
View 2 Replies
View Related
Oct 10, 2007
I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!
View 3 Replies
View Related
Aug 7, 2007
Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.
View 10 Replies
View Related
Jan 16, 2008
How can I insert a value that includes ' ?
My insert string looks like this: "INSERT INTO table(field1) VALUES ( ' " + value1 + " ' )"
When value1 has ' in it, I get an error.
View 5 Replies
View Related
Sep 30, 2005
I have the following code for SQL2000:
It only works if the sub-query returns only 1 values.... anyone knows how I can solve this?
thx a lot!!!
INSERT INTO Table1(SourceName, CreatedBy, CreateDate, IsSuccess, datadate)
SELECT 'Data_01', user, GetDate(), 1,
(
SELECT DISTINCT T1_Dummy.[TRANSACTION DATE]
FROM T1
WHERE T1.[TRANSACTION ID] NOT IN
(
SELECT T.TRANSACTION_ID
FROM T
)
)
FROM T1
GROUP BY [Transaction Date]
View 3 Replies
View Related
Apr 4, 2007
Hi,
I am moving one database to another (different scemas) using SSIS. The destination database uses autogenerated keys. In order to preserve referential integrity I have to keep track of the keys generated when doing inserts in various tables. I use a staging table to save the keys generated by the insert command. I use this as a lookup table later on to find the foreign keys in order to link newly inserted records. The only way that I could find to get the key back after an insert was to create a Script component that does the insert and then executes "SELECT @@IDENTITY". After that I use an OLE DB Command to update the record in the staging database. Is there a better way of doing this? It seems to me that this is not a proper use of the Script component, but if I want to use OLE DB destination or OLE DB Command I cannot get the key back. Also, I am not allowed to use any stored procedures or change the destination database in any way.
View 4 Replies
View Related
Jul 19, 2006
Hello.
I need to insert some records to an accounting table and calculate the balance after that. Thus, other users can be trying to do the same. How to lock the db and make the other users wait until the right moment? I'm using SqlDataSource to do that.
Thanks.
View 7 Replies
View Related
Sep 3, 2006
I have populated an SQLdata table from an XML datasource usinmg the bulk command. In my SQL table is a new column that is not in the XML table which I would like to set to a default value. Would anyone know the best way to do this. So far I can's see how to add this value in the Bulk command. I am happy to create a new command that updates all the null values of this field to a default value but can't seem to do this either as a SQLdatasource or a APP Code/ Dataset. Any suggestions or examples where I can do this.Many thanks in advance
View 1 Replies
View Related
Sep 11, 2006
Hi,I m using Microsoft Visual Studio 2005 and SQL server 2000. I have 2 textboxes and a button, what i wanna do is, when i hit the button, the values in textboxes should be inserted into DB. Would you please help me? Thanks in advance.
View 1 Replies
View Related
Jan 17, 2007
How to insert 100 record at a time by explicit inserting of identity column i.e.., by setting identity column to false
View 4 Replies
View Related
May 5, 2007
Hi friends,I have one text box on my form.i need to insert the data from tat text box to DB without clicking on any button.Now i have written the code under text changed event of that text box.So it is inserting whenever i click on that form.Besides this i need to insert data when i close tat window.But it is not inserting when i close tat window.Plse help me.Thanks in advance
With RegardsLijo Rajan
View 1 Replies
View Related
Jun 6, 2007
I have created a form with several fields etc and validation.
After pressing the submit button i have a
if Page.IsValid then .....etc
But in this then bit I want to do a
INSERT the form details to the db.
I have done inserts etc via gridView etc but I just need a form that lets someone enter info and submit etc, so do not now where to or how to place this code to connect then insert etc
thanks
View 3 Replies
View Related
Sep 18, 2007
Why on earth is this not working, It WILL insert if there are NO apostheres (" ' "), but if I say like, "Cedric's Group" It will error out. I thought this approach was suppose to handle this character?
Thanks for any insight, String sqlStr = "Insert into cardgroups (username,groupname,insertdt,groupid) values (@username,@groupname,@insertdt,@groupid)";
SqlCommand cmd = new SqlCommand(sqlStr, connect);
cmd.Parameters.AddWithValue("@username", Session["memberusername"].ToString());
cmd.Parameters.AddWithValue("@groupname",this.namebox.Text.ToString());
cmd.Parameters.AddWithValue("@insertdt", DateTime.Now.ToString());
cmd.Parameters.AddWithValue("@groupid", myGroupStr);
connect.Open();
cmd.ExecuteNonQuery();
connect.Close();
View 2 Replies
View Related
Oct 21, 2007
I fixed all the free text stuff but now I have another problem. I created a web app one page to enter data and anoter to display it. I have a multiple row text box and if you enter something with returns it it when you display the data it ignores the returns and puts everything on the same line BTW the column type is text
example
this
"want to hest this out.
========================
now I am going to put in some test data and see how it comes out
finished"
will come out like this
"want to hest this out.========================now I am going to put in some test data and see how it comes out finished"
how do you fix this?
View 16 Replies
View Related
Nov 12, 2007
I want to insert a recorde into my table (2 column) : name and Id
id is a primary key and this is the error MSG im getting everytime im trying to insert a record
Error:Cannot insert explicit value for identity column in table 'Customer' when IDENTITY_INSERT is set to OFF.
what is the problem
here is the code :protected void Button2_Click(object sender, EventArgs e)
{
try
{string str = "data source=.;integrated security=true; initial catalog=NH_Project2";
SqlConnection conn = new SqlConnection(str);SqlCommand comm = new SqlCommand("insert into [Customer](Name,Id) values(@custName,@custId)", conn);
comm.CommandType = CommandType.Text;comm.Parameters.AddWithValue("@custName", TextBox1.Text);comm.Parameters.AddWithValue("@custId", TextBox2.Text);
conn.Open();
int rowaff = (int)comm.ExecuteNonQuery();if (rowaff == 1)
{Label4.Visible = true;Label4.Text = "one customer has added to our data base";
}
else
{Label4.Visible = false;Label4.Text = "not added try again";
}
}catch (Exception ex)
{ Response.Write("Error:" + ex.Message);
}
}
View 6 Replies
View Related
Jan 9, 2008
Hey all,
Quick question for ya. If I wanted to insert 1 value into 1 table and another value into another table, how would I do that with closing connections and reopening and whatnot? I am using Visual Web Dev and SQL server 2005 express. I have been trying to mess around with it but I can't figure it out. Here is the situation.
I want to insert a GroupName and GroupDescription that a user fills in in 2 text boxes named GroupNametxt and GroupDescriptiontxt. This data will go into the "Group" table.
I then also want to Insert the data UserID (taken from the aspnet ID table), and GroupName from the Grouptxt.text into a GroupMembership table.
How would I do all this in 1 button click? I know some basic TSQL but I don't know how to handle the opening and closing of connections and whatnot.
Thanks,
Chris
View 2 Replies
View Related
Jan 20, 2008
When using a SQL Server DateTime column to store just times, e.g. '6:00 PM' I've noticed some weird inconsistency.
If I insert a time in a SQL statement, such as... INSERT INTO myTable (StartTime) VALUES ('6:00 PM')
It winds up going in as '1/1/1900 6:00 PM'. This is okay. This is in fact what I want (unless of course the base day for sql server is in fact 12/30/1899, which is my next question).
If, on the other hand, I insert a time value by hand, using SQL Server Management Studio, then after I insert '6:00 PM' it winds up as '<Today's Date> 6:00 PM', i.e. '1/20/2008 6:00 PM'.
Also, if I insert it using a SQL Parameter, such as...
da.InsertCommand.Parameters.Add("@StartTime", SqlDbType.DateTime, 8, "StartTime")
...Then, if StartTime is 6:00 PM again, it also winds up going in as '<Today's Date> 6:00 PM'.
Is there a way to control this behavior (other than to programmatically append a base date to the time I'm inserting)?
Finally, what is the base day for SQL Server 2005? Is it 1/1/1900 or 12/30/1899? I think I've seen both.
Thanks!
Aaron
View 3 Replies
View Related