Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Save An Image To A Byte[] Variable From A Database


i'm trying to read an image file from a database(ms-sql, .mdf) with type image.  Anyone have any ideas on how to do this?  I have a table adapter created but could not assign it to my byte[] variable.  Thanks in advance.




View Complete Forum Thread with Replies

Related Forum Messages:
Cannot Convet Sql Image To Byte[]
I have followed many examples found on this site, but still get an invalid cast execption when I attempt to run code below. the exception is thrown when I try to convert the sql image to a byte[] in the download section of the code.


//
// sqlUploadImage
//
this.sqlUploadImage.CommandText = "INSERT INTO Image_Table (Description, Type, Lenth, DocName) VALUES (@Description," +
" @Type, @Length, @DocName)";
this.sqlUploadImage.Connection = this.sqlConnection2;
this.sqlUploadImage.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Description", System.Data.SqlDbType.VarChar, 50, "Description"));
this.sqlUploadImage.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Type", System.Data.SqlDbType.VarChar, 50, "Type"));
this.sqlUploadImage.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Length", System.Data.SqlDbType.Int, 4, "Lenth"));
this.sqlUploadImage.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DocName", System.Data.SqlDbType.VarChar, 50, "DocName"));
this.sqlUploadImage.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Image", System.Data.SqlDbType.Image, 16, "ImgField"));
this.Button2.Click += new System.EventHandler(this.Button2_Click);
//
// sqlDownLoadImage
//
this.sqlDownLoadImage.CommandText = "SELECT Image_Table.* FROM Image_Table";
this.sqlDownLoadImage.Connection = this.sqlConnection2;

//upload file
private void Button1_Click(object sender, System.EventArgs e)
{
//Get the filename of the pdf file to be uploaded.
string strFilename = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\") +1);

//Get the file type
string strFileType = File1.PostedFile.ContentType;

//Get the file size
int intImageSize = File1.PostedFile.ContentLength;

// Reads the Image
Stream ImageStream = File1.PostedFile.InputStream;

byte[] ImageContent = new byte[intImageSize + 1];
int intStatus = 0;
intStatus = ImageStream.Read(ImageContent, 0, intImageSize);

//Response.Write(strFilename.ToString());
//Response.Write("<br>Image Type: " + strFileType.ToString());
//Response.Write("<br>Image Size: "+intImageSize.ToString());

this.sqlUploadImage.Parameters["@Description"].Value = strFilename;
this.sqlUploadImage.Parameters["@Type"].Value = strFileType;
this.sqlUploadImage.Parameters["@Length"].Value = intImageSize;
this.sqlUploadImage.Parameters["@DocName"].Value = "TestPDF";
this.sqlUploadImage.Parameters["@Image"].Value = ImageContent;

try
{
this.sqlConnection2.Open();
this.sqlUploadImage.ExecuteNonQuery();

this.Label2.Text = "File Uploaded Successfully";
this.Button2.Visible = true;
}
catch(SqlException ex)
{
Response.Write(ex.ToString());
}
finally
{
this.sqlConnection2.Close();
}
}


//download file
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
this.sqlConnection2.Open();
SqlDataReader r = this.sqlDownLoadImage.ExecuteReader(CommandBehavior.CloseConnection);


if(r.Read())
{

Response.ContentType = r["Type"].ToString();
byte[] image = (byte[])r["ImgField"];
Response.BinaryWrite(image);
}
}
catch(SqlException ex)
{
Response.Write(ex.ToString());
}
finally
{
this.sqlConnection2.Close();
}
}

View Replies !
How To Save Image In Sql Server And Display That Image In Datagrid??
Hay Friend's
Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.
 Thank's
Amit

View Replies !
Why Can Varchar Datatype Variable Only 4000 Byte?
Why can varchar datatype variable only 4000 byte?
For example:
in a storedprocedure
declare @aa varchar(8000)
......
while
select @aa=@aa+@otherinfo
end
when the length is more than 4000 ,the data in the behind will be lost

View Replies !
Help With Error 'value Of Type Byte Canot Be Converted To 1 Dimensional Array Of Byte'
hi
i am getting an error with my code, it says 'value of type byte canot be converted to 1 dimensional array of byte' do you know why and how i can correct this error, the follwoing is my code.
can anyone help me correct the error and let me know ow to solve it
thanks for any help givenPublic Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequestDim myConnection As New Data.SqlClient.SqlConnection("ConnectionString")
myConnection.Open()
 Dim sql As String = "Select Image_Content from ImageGallery where Img_Id=@ImageId"Dim cmd As New Data.SqlClient.SqlCommand(sql, myConnection)cmd.Parameters.Add("@imgID", Data.SqlDbType.Int).Value = context.Request.QueryString("id")
cmd.Prepare()Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader()
dr.Read()
context.Response.ContentType = dr("imgType").ToString()context.Response.BinaryWrite(CByte(dr("imgData"))) ----- this is the line with the error
End Sub

View Replies !
Image File Save To DB
How to save image file to database?
Which control use best?

View Replies !
Image Save To SQL Server
When I am trying to save byte[] of an image to SQL server which is having an image column, I am getting an error like this " A severe error occured on the current command. The results, if any, should be discarded.". I am trying to save through a stored procedure.
In the sp also, the datatype is image.

Can you give a reply to this?

View Replies !
How To Save Image To SQL Server 2000
Hi,

I have to store images in database. I have a table which contains field picture which is an image.

How can I do this using C# ?

In Visual Studio .NET i found a code how to obtain BLOB values from the database but I do not know how to do upload an image to the database.

Thanks in advance for your help.

Rafi

View Replies !
How To Save Image And Display On The Page When Using Sql Sserver 7.0
i am know how to save normal data to the data base bt i am surprise when i am read u cant saving image normallly
if any one can help me send Example to my Email :
yousefyousef2001@yahoo.com
 
thx

View Replies !
Save Upload Image To Db Using Stored Procedure Problem
I am trying to save an uploaded image and its associated info to sql server database using a stored procedure but keep getting trouble. When trying to save, the RowAffected always return -1. but when i debug it, I dont' see problem both from stored procedure server
explore and codebehind. it looks to me every input param contains correct value(such as the uploaded image file name, contentType and etc). well, for the imgbin its input param value returns something like "byte[] imgbin={Length=516}". Below is my code, could anyone help to point out what did I do wrong?
Thank you.

================================================
CREATE PROCEDURE [dbo].[sp_SaveInfo]
(
@UserID varchar(12),
@Image_FileName nvarchar(50),
@Image_ContentType nvarchar(50),
@Image_ImageData image,
@Create_DateTime datetime)

AS
set nocount on

insert ExpertImage(UserID, Image_FileName, Image_ContentType, Image_ImageData, Image_ReceiveDateTime)
values(@UserID, @Image_FileName, @Image_ContentType, @Image_ImageData, @Create_DateTime)
GO

private void Submit1_ServerClick(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
Stream imgStream = File1.PostedFile.InputStream;
int imgLen=File1.PostedFile.ContentLength;
string imgContentType = File1.PostedFile.ContentType;
string imgName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\") + 1);
byte[] imgBinaryData = new byte[imgLen];
int n=imgStream.Read(imgBinaryData, 0, imgLen);
int RowsAffected = SaveInfo(imgName,imgBinaryData, imgContentType);
if(RowsAffected > 0)
{
..
}
else
{
..
}
}
}

public int SaveInfo(string imgName, byte[] imgbin, string imgcontenttype)
{

SqlConnection objConn = new DSConnection().DbConn;
SqlCommand objCMD = new SqlCommand("sp_SaveInfo", objConn);
objCMD.CommandType = CommandType.StoredProcedure;

objCMD.Parameters.Add("@UserID", SqlDbType.VarChar, 12);
objCMD.Parameters["@UserID"].Value = txtMemberID.Text.ToString();
objCMD.Parameters["@UserID"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Create_DateTime", SqlDbType.DateTime);
objCMD.Parameters["@Create_DateTime"].Value = DateTime.Now.ToLongTimeString();
objCMD.Parameters["@Create_DateTime"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Image_FileName", SqlDbType.NVarChar, 50);
objCMD.Parameters["@Image_FileName"].Value = imgName;
objCMD.Parameters["@Image_FileName"].Direction = ParameterDirection.Input;
objCMD.Parameters.Add("@Image_ContentType", SqlDbType.NVarChar, 50);
objCMD.Parameters["@Image_ContentType"].Value = imgcontenttype;
objCMD.Parameters["@Image_ContentType"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Image_ImageData", SqlDbType.Image);
objCMD.Parameters["@Image_ImageData"].Value = imgbin;
objCMD.Parameters["@Image_ImageData"].Direction = ParameterDirection.Input;


int numRowsAffected = objCMD.ExecuteNonQuery();
return numRowsAffected;

}

View Replies !
Save Sql SUM() Into A Variable
 I'm just wondering if we can save sql aggregate functions into a variable. I have this query:select company, dept, sum(pers) as pers1, sum(amount) as amount1,sum(amount)/sum(pers) as wage from xxtestsumgroup by company, dept  instead of calling sum(amount) and sum(pers) again in "sum(amount)/sum(pers) as wage",I would like to save them in some kinda variable in the select clause so it will save process time.Sorry but im new to sql programming. So thx for your understanding. 

View Replies !
Save Dr Property To Variable
 how do you store a datareader propety to a variable? Below is my current code. I have already declared my connectionString and sqlComm objects, as well as the userName and such. I need to store the value from the dr to the variables, UserName, UserPass, and serverName. ThanksTry
sqlCon.Open()
dr = sqlComm.ExecuteReader
While dr.Read
userName = dr("uName").ToString
LogInfo("userName = " & userName)

userPass = dr("uPass").ToString
LogInfo("userPass = " & userPass)

serverName = dr("sName").ToString
LogInfo("serverName = " & serverName)
End While
dr.Close()
Catch obug As Exception
LogEvent("Credentials Error: " & obug.Message)
Finally
sqlCon.Close()
End Try
 

View Replies !
How To: Store And Retrieve Images In A Database As A Byte Array.
I€™ve inherited a project from one of the guys on our team who will be out sick for a while.  He developed two for marshaling data between System.Drawing.Image and System.Byte().  He€™s storing the byte array data in a database image field.
 
I€™ve retrieved the byte array data from his database image fields and have successfully converted them to images using his ConvertByteArrayToImage method below.  I have also converted and image to a byte array with his ConvertImageToByteArray method below and succfully stored the data in a database image field.  However, when I retrieve the byte array data that I stored in the database the last line in his ConvertByteArrayToImage method throws an exception (Parameter is not valid).  I€™ve not been able to find a working copy of his code that€™s storing the byte array data.  Does anyone see anything I€™m overlooking?
 
Imports System.Drawing
Imports System.IO
 
Public Sub InsertImage(ByVal pFilename As String)
 
        Try
 
            Dim lImage As Image
            Dim lBA() As Byte
            Dim lSQL As String
            Dim lQuery As Alcon.SQLServer.Database.clsQuery
            Dim lParameters As New Alcon.SQLServer.Database.clsParameters
 
            lImage = Image.FromFile(pFilename)
 
            ConvertImageToByteArray(lImage, lBA)
 
            ' Initialization
            lQuery = New Alcon.SQLServer.Database.clsQuery(mConnection)
 
            lSQL = ""
            lSQL += "INSERT INTO [TBL_PCL_LENS_DATA]("
            lSQL += "[SerialNumber], "
            lSQL += "[ProcessedDate], "
            lSQL += "[CartonLabelImage]) "
            lSQL += "VALUES ("
            lSQL += "@SerialNumber, "
            lSQL += "@ProcessedDate, "
            lSQL += "@CartonLabelImage "
            lSQL += ")"
 
            lParameters.Add("@SerialNumber", SqlDbType.VarChar, ParameterDirection.Input, mSerialNumber)
            lParameters.Add("@ProcessedDate", SqlDbType.DateTime, ParameterDirection.Input, Now)
            lParameters.Add("@CartonLabelImage", SqlDbType.Image, ParameterDirection.Input, lBA)
 
            ' Execute query
            lQuery.Execute(lSQL, lParameters)
 
        Catch ex As Exception
            Throw
        End Try
 
End Sub
 
ConvertByteArrayToImage(ByVal pBA() As Byte, ByRef pImage As Image)
 
Try
 
            ' Declaration
            Dim lMS As MemoryStream
 
            ' Initialization
            lMS = New MemoryStream(pBA, 0, pBA.Length)
            lMS.Write(pBA, 0, pBA.Length)
            lMS.Position = 0
 
            ' Create image
            pImage = Image.FromStream(lMS, True)
 
        Catch ex As Exception
            Throw
        End Try
 
End Sub
 
ConvertImageToByteArray(ByVal pImage As Image, ByRef pBA() As Byte)
 
        Try
 
            ' Declaration
            Dim lBM As Bitmap
            Dim lBR As BinaryReader
            Dim lMS As New MemoryStream
 
            ' Initialization
            lBM = New Bitmap(pImage)
            lBM.Save(lMS, Imaging.ImageFormat.Png)
            lBR = New BinaryReader(lMS)
 
            ' Create byte array
            pBA = lBR.ReadBytes(lMS.Length)
 
        Catch ex As Exception
            Throw
        End Try
 
End Sub

View Replies !
SQL2005 Data Import Error, Unicode Data Is Odd Byte Size For Column &&<n&&>. Should Be Even Byte Size
Hi, I have a problem importing data from SQL Server 2000 'text' columns to SQL Server 2005 nvarchar(max) columns.  I get the following error when encountering a transfer of any column that matches the above.
The error is copied below,

Any help on this greatly appreciated...

ERROR : errorCode=-1071636471 description=An OLE DB error has occurred. Error code: 0x80004005.An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Unicode data is odd byte size for column 3. Should be even byte size.". helpFile=dtsmsg.rll helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC} (Microsoft.SqlServer.DtsTransferProvider)


Many thanks

View Replies !
Image Located On Web, Url For Image Stored In Database
 

Hi,
     I have a website and i am uploading the gif image to the database. i have used varchar(500) as the datatype and i am saving the file in the webserver so the path to it c:intepub....a.gif

 
my upload table has the folliwing feilds
UploadId Int Identity, Description, FileName, DiskPath varchar(500), weblocation varchar(500). I have a main sproc for the report where i am doing a inner join with other table to get the path of the gif..
 
So my question is how can i get a picture to show up on the report. .
 What kinda datatype the gif file should be stored in the database? If it is stored as a varchar how can i access it and what is best way to reference that particular.
 
any help will appreciated....
Regards
Karen
 

View Replies !
How To Store Image Datatype Value To A Variable?
I have image type col.I'm trying to do the following,DECLARE @Data varbinary(16)SET @Data = (select imageCol from Table1 where id=3)As image datatype returns varbinary value, so I want to store image col value to a varbinary variable(or any other type variable, eg., varchar). But getting following error,========================================Server: Msg 279, Level 16, State 3, Line 2The text, ntext, and image data types are invalid in this subquery or aggregate expression.========================================Is there anyway to store image datatype value to a variable?Cheers.

View Replies !
SQL Server 2005 - Save Tran Save Point Name Case Sensitive?
Hello:I didn't find any documentation that notes save point names are casesensitive, but I guess they are...Stored Proc to reproduce:/* START CODE SNIPPET */If Exists (Select * From sysobjects Where Type = 'P' and Name ='TestSaveTran')Drop Procedure dbo.TestSaveTranGoCreate Procedure dbo.TestSaveTranAsBeginDeclare@tranCount int--Transaction HandlingSelect @tranCount = @@TRANCOUNTIf (@tranCount=0)Begin Tran localtranElseSave Tran localtranBegin Try--Simulate Error While ProcessingRAISERROR('Something bad happened', 16, 1)/*If this proc started transaction then commit it,otherwise return and let caller handle transaction*/IF (@tranCount=0)Commit Tran localtranEnd TryBegin Catch--Rollback to save pointRollback Tran LOCALTRAN --<< NOTE case change--Log Error--Reraise ErrorEnd CatchEndGo--Execute Stored ProcExec dbo.TestSaveTran/*Should receive the following message:Cannot roll back LOCALTRAN. No transaction or savepoint of that namewas found.*//* END CODE SNIPPET */What is really strange, if there is a transaction open, then no erroris thrown. So if you execute as so:/* START CODE SNIPPET */Begin Tran--Execute Stored ProcExec dbo.TestSaveTran/* END CODE SNIPPET */There is no "Cannot roll back LOCALTRAN...." message.Questions:1-)Can someone confirm save point names are case sensitve and this isnot happening because of a server setting?2-)Is this a logic error that I am not seeing in the example codeabove?We have changed our code to store the save point name in a variable,which will hopefully mitigate this "problem".Thx.

View Replies !
?Can You Save XML To A Database?
The XML generated by notifications object needs to be saved. Where do I save it - in the database. That will still be stored in a table - with drawbacks!

View Replies !
Save DML Of Database
Hi,
I need to save all the DML related queries which is executed in my Database
how can i do it?
what are the possible ways to do it.

View Replies !
Save Data From Xml Into Database?
i have an xml file, it looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?><shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd">  <orderperson>John Smith</orderperson>  <shipto>    <name>Ola Nordmann</name>    <address>Langgt 23</address>    <city>4000 Stavanger</city>    <country>Norway</country>  </shipto>  <item>    <title>My Title</title>    <quantity>1</quantity>    <price>10.12</price>  </item>  <item>    <title>Hide your heart</title>    <quantity>1</quantity>    <price>9.90</price>  </item></shiporder>
how can i save this into a database(Sql) using a procedure
or..there is another way to do this?
im a newbie

View Replies !
Save A Bitmap Into The Database
Hi all,Does anybody know how to save a bitmap into SQL Server 2005 using the IMAGE type (do I have to use this type?) and, then, retrieve it?? I've checked some examples, but all of them very confusing!!! Thanks in advance!!!cu

View Replies !
How To Save Pdf Files To SQL Database?
Hi all,
Can someone please brief me on how to save 'pdf' files(there are about 15 files) into a SQL database and retrieve/open it from a datagrid?
I have about 15 pdf files on my webserver and need to save it in the SQL database, so every pdf file saved in the database will have a primary key and the file will be saved either as 'ntext' or 'binary' type...I just have this rough idea.
If someone has a ready code in VB.net then nothing better( i know thats a shortcut :) but it will help me like a tutorial. C# code will do too, I can then convert the code to Vb.net
Thanks a ton.

View Replies !
How To Save Xml Document In Database
I am trying to save xml document in database. What would be the most indicated data type to save that kind of information?

Thanks for any help.

View Replies !
How To Save Arrays In SQL Database?
Hi,
I'm using Visual Studio and Visual Basic to save data about members in a database.
I use SQL-database as it's included.
However, I'm new to this saving in the datbase and wonder how I can at the best save data about a member without having to index each value in the arrays:
The array has 2 index and is declared
dim Results(6, 50) as string
Of course, I can do results11, results12,... results150, results21, ...results250....
But it seems rather awkward to do it this way. I'm sure that there is a better way.
Thanks, any assistance is appriciated!
Best wishes, Per 

View Replies !
Database Save And Restore
Hello,

A database EntryForm has a MenuStrip. How could the Menustrip implemented that it would have a Save and Restore data to the database for backup purposes?

What is the Menustrip for? None of the  standard Items seems to work. What can be printed or previewed?

This question is NOT about how to save the data into the database from the EntryForm.

Thanks for any answer,

 

View Replies !
Save TextBox To Database As New Row?
(VB 2005 Express) I have a textbox linked to a DataTable (database). I want to save its text into the database as a new row. What is the VB code? The following is not working.

Me.Validate()
Me.myDataTableBindingSource.EndEdit()
Me.myDataTableTableAdapter.Update(Me.myDatabaseDataSet.myDataTable)

Thanks for any help.

View Replies !
How Can We Save A Table In Other Database
1-I want to save records from a table located in my database1 on Server1 to a non existing table in another database2 in another server2. (The destination table doesn t exist, I want it to be created with T-SQL). How can I do that using T-SQL
2- Also, is there an other better practice to back up my table before I do some dammage inintentially and destroy the table or the records forever or does SQL server do that automatically for us.
Thanks a lot for your advice.

View Replies !
How To Save Float Value From Textbox To A Database.
 
I have a sql table in which field ExchangeRate is defined as float. When i tries to enter data into ExchangeRate field using LINQ i get follwoing error.
"String or binary data would be truncated.The statement has been terminated."
 
My code is as follows
ExchangeRate = float.Parse(txtRate.Text)
I tried with
ExchangeRate = double.Parse(txtRate.Text)
 
I would appreciate any help.
 
 
 
 
 

View Replies !
Save File Into The Sql Server Database
Hi,
I want to upload a file (e.g. .xls, .pdf, .doc) and save into the Sql Server 2000 database through the web interface, and then to download this file. Any idea???

View Replies !
How To Save Contents Of Text Box To Database?
Hi,
For some reason I can't use the edit, update or insert features on my remote shared server, so I am looking to create a web page that has text boxes on it, that I can enter data into, that will be saved into my database.
 
This is opposed to entering the data directly into the database itself. I want to be able to use a webpage, for simply adding new data, and saving it so that the new data updates and saves over the top of the old data.
What are the steps involved in doing this?
Any example code for just one text box would be appreciated, I could then extend it to suit my needs. Tia.

View Replies !
How To: Save Form Results To Database
Hi !

I am creating a website with a form that users can fill up the
information. This form is about the school's information of the users.
After fill up this form, the users will have to click the submit button
that will submit the form to be saved in a database.

I have created the database for that form. My question is how can I
save the result of this form to my database. Let's say I have 5
textboxes in that form, name, school's name, school's address, major,
and comments.

thanks a lot in advanced!

View Replies !
Problem When I Save Data In Database
Hi

I have problem in the data when I save it in database !!!

From Windows Application I Send (nText) Data to SQL Server Database in Web Server but when I try to explore it in SQL Server Enterprise manager or ny SQL Server DB Manager I see the Fields of (nText) Data is empty but when I try to brows the data in ASP.NET page I get it like the following

??? ??? ??? ????? ??????? ?? ??? ??? ?????, ????? ?????? ?????? ?????? ?????????. ????
??????". ?? ????????? ???? ???? ????? ?????, ?? ????? ??????? ??????.
???? ????, ??????? ??? ??? ??????? ?????, ??? ???? ?? ?????? ?? ????? ??????


So I thing the data has been damaged!!
Why this problem... And how can I solve it??

The Problem only in (nText) Data ..

And thanks with my best regarding??

View Replies !
BCP Certain Columns To Save Space In Database
6.0
6
1 SQLCHAR 0 7 "" 1 Ord_Nbr
2 SQLCHAR 0 1 "" 2 Ord_Type
3 SQLCHAR 0 3 "" 3 Locn
4 SQLCHAR 0 16 "" 0 Po_nbr
5 SQLCHAR 0 2 "" 0 Vers
6 SQLCHAR 0 4 "" 6 Int_Code
7 SQLCHAR 0 1 "
" 0 RT_Req

I am using bcp to import data into a table usign format file. when I put 0 in the table column(as it is shown here) it means that I am not bcp in the field values into the table. what I get in return is (NULL) for all those columns that has 0 in the format file.....
My Questions is Am I saving space in the table when I use this process, or (NULL) will take space like an actual value ?

I hope I explained my question clearly... Thanks for your input

regards
Ali

View Replies !
Save Database E-R Diagram To File
HI,
I was wondering if it is possible to save the database E-R diagram to file in
MS SQL server 7?

Regards
Guy

View Replies !
Save And Retrieve RTF TEXT FROM SQL DATABASE
Hi,
i have a richtextbox control in my application, and want to know how to save and retrieve formatted text in a MS SQL DB.

I found this example in the forum, but I don't know how to use it. Can you please help me solve the problem? Where should I write the code below?

 



I've just tried it and able to do this successfully.

I basically did this:
load the RTF into the RTB control
created a SQL command, simple basic insert statement:

 









SqlCommand theSQLCommand = new SqlCommand("INSERT INTO [TableName] (Field) VALUES (@p1)");
SqlParameter theSQLParameter = new SqlParameter("@p1", SqlDbType.Text);
theSQLParameter.Value = this.theRichTextBox.RTF;
theSQLCommand.Parameters.Add(theSQLParameter);
theSQLCommand.Connection = new SqlConnection(ConnectionString);
theSQLCommand.Connection.Open();
theSQLCommand.ExecuteNonQuery();
theSQLCommand.Connection.Close();

 

 

then to retrieve it, I did this, again, specifically for this example

 









this.theRichTextBox.Text = String.Empty;
SqlCommand theSQLCommand = new SqlCommand("SELECT [Field] FROM [TableName] WHERE [ID] = 1");
theSQLCommand.Connection = new SqlConnection(ConnectionString);
theSQLCommand.Connection.Open();
SqlDataReader theReader = theSQLCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (theReader.Read())
{
   this.theRichTextBox.RTF = theReader.GetValue(0).ToString();
}
theSQLCommand.Connection.Close();

 

 

And was able to do this fine and got all the formatting etc... correctly.

View Replies !
HELP WITH DATABASE SAVE FOR MINING PROGRAM
I use the code following to insert new data to my database. I have two tables in my database DEMOGRAFICS AND VISIT, related each other one to many

START OF CODE

Dim strSQL As String

'Check for sql problems

Select Case StateFlag

Try

' Build Insert statement to insert new demografics into the demografics table

strSQL = "INSERT INTO VISIT (CODE, CODE_VISIT, DATE_VISIT, STAFF_YES, STAFF_NO, STAFF_NOT_SURE, OZOS_NUM_ONE, OZOS_NUM_MANY, OZOS_POS, OZOS_TYPE_CYST, OZOS_TYPE_COMP," & _

"OZOS_VOL, OZOS_COLOR, OZOS_RESULT, D_G_OZODIS_IPER, D_G_HASHI," & _

"D_G_OXI, D_G_ST_THYRO, D_G_IPOXI, D_G_EIDIKI, D_G_NO_TAKSI, D_G_AYTO," & _

"D_B_THILO, D_B_PIKI, D_B_META, D_B_LOW, D_B_ANAPL, D_B_MIELO, D_B_ATAXI, D_B_LEMFO, D_B_OTHER," & _

"D_B_NEO_THILO, D_B_NEO_OXI, D_SUSPICIOUS, D_LIMIT_THILO, D_LIMIT_OXI," & _

"O_PARA, O_LEMFO, O_BRAXO, O_THYRO, O_FAGO, O_MESE, O_KAROTI, O_SIELO," & _

"EPI_SUB_COL_BIG, EPI_SUB_COL_SMALL, EPI_SUB_BLOOD, EPI_SUB_AMI, EPI_CYTO_SMALL, EPI_CYTO_BIG, " & _

"EPI_SUB_ADD_LEMFO_BIG, EPI_SUB_ADD_LEMFO_SMALL, EPI_SUB_ADD_NEKRO, EPI_SUB_ADD_ASB," & _

"EPI_SUB_ADD_LIPO, EPI_SUB_ADD_FAGO_BIG, EPI_SUB_ADD_FAGO_SMALL, EPI_SUB_ADD_POLI," & _

"EPI_SUB_ADD_GIGA, EPI_SUB_ADD_OTHER, EPI_SUB_ADD_DET, EPI_SUB_ADD_SIND, EPI_SUB_ADD_PSAM, EPI_SUB_ADD_INO, EPI_SUB_ADD_ISTIO, EPI_CELL_SINO_GOOD, EPI_CELL_SINO_LOOSE," & _

"EPI_ARCHI_MONO, EPI_ARCHI_MICRO, EPI_ARCHI_THILA_BIG, EPI_ARCHI_THILA_SMALL, EPI_ARCHI_SIMPA," & _

"EPI_ARCHI_THILO_BIG, EPI_ARCHI_THILO_SMALL, EPI_ARCHI_FREE, CYTO_CELL_MONO, CYTO_CELL_DIP," & _

"CYTO_CELL_POLI, CYTO_CELL_THILA, CYTO_CELL_ATI_BIG, CYTO_CELL_ATI_SMALL, CYTO_CELL_EPI," & _

"CYTO_CELL_OXI, CYTO_CELL_MORFI_ANI, CYTO_CELL_MORFI_OMA, CYTO_CELL_MORFI_POLI, CYTO_CELL_LIMIT_DEF, CYTO_CELL_LIMIT_NOT_DEF," & _

"CYTO_CELL_PLASMA_ATRA, CYTO_CELL_PLASMA_KLAS, CYTO_CELL_PLASMA_PLASMA, CYTO_CELL_PLASMA_DIA, CYTO_CELL_PLASMA_POLIG, CYTO_CELL_PLASMA_KOK, CYTO_CELL_PLASMA_KAINO," & _

"CYTO_NUCL_POS_NOT_CENTER, CYTO_NUCL_POS_CENTER, CYTO_NUC_MORFI_ANI, CYTO_NUC_MORFI_ESO, CYTO_NUC_MORFI_PICNO, CYTO_NUC_MORFI_ISO," & _

"CYTO_NUC_MORFI_SINO, CYTO_NUC_MORFI_PIRI, CYTO_NUC_MORFI_POLI)" & _

"VALUES (@CODE, @CODE_VISIT, @DATE_VISIT, @STAFF_YES, @STAFF_NO, @STAFF_NOT_SURE, @OZOS_NUM_ONE, @OZOS_NUM_MANY, @OZOS_POS, @OZOS_TYPE_CYST, @OZOS_TYPE_COMP," & _

"@OZOS_VOL, @OZOS_COLOR, @OZOS_RESULT, @D_G_OZODIS_IPER, @D_G_HASHI," & _

"@D_G_OXI, @D_G_ST_THYRO, @D_G_IPOXI, @D_G_EIDIKI, @D_G_NO_TAKSI, @D_G_AYTO," & _

"@D_B_THILO, @D_B_PIKI, @D_B_META, @D_B_LOW, @D_B_ANAPL, @D_B_MIELO, @D_B_ATAXI, @D_B_LEMFO, @D_B_OTHER," & _

"@D_B_NEO_THILO, @D_B_NEO_OXI, @D_SUSPICIOUS, @D_LIMIT_THILO, @D_LIMIT_OXI," & _

"@O_PARA, @O_LEMFO, @O_BRAXO, @O_THYRO, @O_FAGO, @O_MESE, @O_KAROTI, @O_SIELO," & _

"@EPI_SUB_COL_BIG, @EPI_SUB_COL_SMALL, @EPI_SUB_BLOOD, @EPI_SUB_AMI, @EPI_CYTO_SMALL, @EPI_CYTO_BIG, " & _

"@EPI_SUB_ADD_LEMFO_BIG, @EPI_SUB_ADD_LEMFO_SMALL, @EPI_SUB_ADD_NEKRO, @EPI_SUB_ADD_ASB," & _

"@EPI_SUB_ADD_LIPO, @EPI_SUB_ADD_FAGO_BIG, @EPI_SUB_ADD_FAGO_SMALL, @EPI_SUB_ADD_POLI," & _

"@EPI_SUB_ADD_GIGA, @EPI_SUB_ADD_OTHER, @EPI_SUB_ADD_DET, @EPI_SUB_ADD_SIND, @EPI_SUB_ADD_PSAM, @EPI_SUB_ADD_INO, @EPI_SUB_ADD_ISTIO, @EPI_CELL_SINO_GOOD, @EPI_CELL_SINO_LOOSE," & _

"@EPI_ARCHI_MONO, @EPI_ARCHI_MICRO, @EPI_ARCHI_THILA_BIG, @EPI_ARCHI_THILA_SMALL, @EPI_ARCHI_SIMPA," & _

"@EPI_ARCHI_THILO_BIG, @EPI_ARCHI_THILO_SMALL, @EPI_ARCHI_FREE, @CYTO_CELL_MONO, @CYTO_CELL_DIP," & _

"@CYTO_CELL_POLI, @CYTO_CELL_THILA, @CYTO_CELL_ATI_BIG, @CYTO_CELL_ATI_SMALL, @CYTO_CELL_EPI," & _

"@CYTO_CELL_OXI, @CYTO_CELL_MORFI_ANI, @CYTO_CELL_MORFI_OMA, @CYTO_CELL_MORFI_POLI, @CYTO_CELL_LIMIT_DEF, @CYTO_CELL_LIMIT_NOT_DEF," & _

"@CYTO_CELL_PLASMA_ATRA, @CYTO_CELL_PLASMA_KLAS, @CYTO_CELL_PLASMA_PLASMA, @CYTO_CELL_PLASMA_DIA, @CYTO_CELL_PLASMA_POLIG, @CYTO_CELL_PLASMA_KOK, @CYTO_CELL_PLASMA_KAINO," & _

"@CYTO_NUCL_POS_NOT_CENTER, @CYTO_NUCL_POS_CENTER, @CYTO_NUC_MORFI_ANI, @CYTO_NUC_MORFI_ESO, @CYTO_NUC_MORFI_PICNO, @CYTO_NUC_MORFI_ISO," & _

"@CYTO_NUC_MORFI_SINO, @CYTO_NUC_MORFI_PIRI, @CYTO_NUC_MORFI_POLI)"

 

sqlCmd = New SqlCommand(strSQL, connThyroid)

connThyroid.Open()

sqlCmd.Parameters.Add("@CODE", curcode)

sqlCmd.Parameters.Add("@CODE_VISIT", get_code_visit + 1)

sqlCmd.Parameters.Add("@DATE_VISIT", Me.DateTimePicker1.Value)

sqlCmd.Parameters.Add("@STAFF_YES", Me.CheckBox54.CheckState)

sqlCmd.Parameters.Add("@STAFF_NO", Me.CheckBox55.CheckState)

sqlCmd.Parameters.Add("@STAFF_NOT_SURE", Me.CheckBox86.CheckState)

sqlCmd.Parameters.Add("@OZOS_NUM_ONE", Me.CheckBox56.CheckState)

sqlCmd.Parameters.Add("@OZOS_NUM_MANY", Me.CheckBox57.CheckState)

sqlCmd.Parameters.Add("@OZOS_POS", Me.ComboBox1.Text)

sqlCmd.Parameters.Add("@OZOS_TYPE_CYST", Me.CheckBox58.CheckState)

sqlCmd.Parameters.Add("@OZOS_TYPE_COMP", Me.CheckBox59.CheckState)

sqlCmd.Parameters.Add("@OZOS_VOL", Me.TextBox8.Text)

sqlCmd.Parameters.Add("@OZOS_COLOR", Me.ComboBox5.Text)

sqlCmd.Parameters.Add("@OZOS_RESULT", Me.TextBox1.Text)

sqlCmd.Parameters.Add("@D_G_OZODIS_IPER", Me.CheckBox60.CheckState)

sqlCmd.Parameters.Add("@D_G_HASHI", Me.CheckBox61.CheckState)

sqlCmd.Parameters.Add("@D_G_OXI", Me.CheckBox62.CheckState)

sqlCmd.Parameters.Add("@D_G_ST_THYRO", Me.CheckBox63.CheckState)

sqlCmd.Parameters.Add("@D_G_IPOXI", Me.CheckBox64.CheckState)

sqlCmd.Parameters.Add("@D_G_EIDIKI", Me.CheckBox65.CheckState)

sqlCmd.Parameters.Add("@D_G_NO_TAKSI", Me.CheckBox66.CheckState)

sqlCmd.Parameters.Add("@D_G_AYTO", Me.CheckBox95.CheckState)



sqlCmd.Parameters.Add("@D_B_THILO", Me.CheckBox68.CheckState)

sqlCmd.Parameters.Add("@D_B_PIKI", Me.CheckBox87.CheckState)

sqlCmd.Parameters.Add("@D_B_META", Me.CheckBox97.CheckState)

sqlCmd.Parameters.Add("@D_B_LOW", Me.CheckBox96.CheckState)

sqlCmd.Parameters.Add("@D_B_ANAPL", Me.CheckBox75.CheckState)

sqlCmd.Parameters.Add("@D_B_MIELO", Me.CheckBox69.CheckState)

sqlCmd.Parameters.Add("@D_B_ATAXI", Me.CheckBox70.CheckState)

sqlCmd.Parameters.Add("@D_B_LEMFO", Me.CheckBox71.CheckState)

sqlCmd.Parameters.Add("@D_B_OTHER", Me.CheckBox72.CheckState)

sqlCmd.Parameters.Add("@D_B_NEO_THILO", Me.CheckBox73.CheckState)

sqlCmd.Parameters.Add("@D_B_NEO_OXI", Me.CheckBox74.CheckState)



sqlCmd.Parameters.Add("@D_SUSPICIOUS", Me.CheckBox67.CheckState)



sqlCmd.Parameters.Add("@D_LIMIT_THILO", Me.CheckBox76.CheckState)

sqlCmd.Parameters.Add("@D_LIMIT_OXI", Me.CheckBox77.CheckState)



sqlCmd.Parameters.Add("@O_PARA", Me.CheckBox85.CheckState)

sqlCmd.Parameters.Add("@O_LEMFO", Me.CheckBox78.CheckState)

sqlCmd.Parameters.Add("@O_BRAXO", Me.CheckBox79.CheckState)

sqlCmd.Parameters.Add("@O_THYRO", Me.CheckBox80.CheckState)

sqlCmd.Parameters.Add("@O_FAGO", Me.CheckBox81.CheckState)

sqlCmd.Parameters.Add("@O_MESE", Me.CheckBox82.CheckState)

sqlCmd.Parameters.Add("@O_KAROTI", Me.CheckBox83.CheckState)

sqlCmd.Parameters.Add("@O_SIELO", Me.CheckBox84.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_COL_BIG", Me.CheckBox1.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_COL_SMALL", Me.CheckBox2.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_BLOOD", Me.CheckBox3.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_AMI", Me.CheckBox90.CheckState)

sqlCmd.Parameters.Add("@EPI_CYTO_SMALL", Me.CheckBox4.CheckState)

sqlCmd.Parameters.Add("@EPI_CYTO_BIG", Me.CheckBox5.CheckState)



sqlCmd.Parameters.Add("@EPI_SUB_ADD_LEMFO_BIG", Me.CheckBox8.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_LEMFO_SMALL", Me.CheckBox9.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_NEKRO", Me.CheckBox10.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_ASB", Me.CheckBox11.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_LIPO", Me.CheckBox12.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_FAGO_BIG", Me.CheckBox14.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_FAGO_SMALL", Me.CheckBox13.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_POLI", Me.CheckBox15.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_GIGA", Me.CheckBox16.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_OTHER", Me.CheckBox17.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_DET", Me.CheckBox18.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_SIND", Me.CheckBox19.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_PSAM", Me.CheckBox89.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_INO", Me.CheckBox91.CheckState)

sqlCmd.Parameters.Add("@EPI_SUB_ADD_ISTIO", Me.CheckBox92.CheckState)



sqlCmd.Parameters.Add("@EPI_CELL_SINO_GOOD", Me.CheckBox6.CheckState)

sqlCmd.Parameters.Add("@EPI_CELL_SINO_LOOSE", Me.CheckBox7.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_MONO", Me.CheckBox20.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_MICRO", Me.CheckBox21.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_THILA_BIG", Me.CheckBox22.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_THILA_SMALL", Me.CheckBox23.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_SIMPA", Me.CheckBox24.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_THILO_BIG", Me.CheckBox25.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_THILO_SMALL", Me.CheckBox26.CheckState)

sqlCmd.Parameters.Add("@EPI_ARCHI_FREE", Me.CheckBox27.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_MONO", Me.CheckBox28.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_DIP", Me.CheckBox29.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_POLI", Me.CheckBox30.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_THILA", Me.CheckBox31.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_ATI_BIG", Me.CheckBox32.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_ATI_SMALL", Me.CheckBox39.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_EPI", Me.CheckBox33.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_OXI", Me.CheckBox34.CheckState)



sqlCmd.Parameters.Add("@CYTO_CELL_MORFI_ANI", Me.CheckBox40.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_MORFI_OMA", Me.CheckBox41.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_MORFI_POLI", Me.CheckBox42.CheckState)



sqlCmd.Parameters.Add("@CYTO_CELL_LIMIT_DEF", Me.CheckBox35.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_LIMIT_NOT_DEF", Me.CheckBox36.CheckState)



sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_ATRA", Me.CheckBox43.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_KLAS", Me.CheckBox44.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_PLASMA", Me.CheckBox45.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_DIA", Me.CheckBox46.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_POLIG", Me.CheckBox88.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_KOK", Me.CheckBox93.CheckState)

sqlCmd.Parameters.Add("@CYTO_CELL_PLASMA_KAINO", Me.CheckBox94.CheckState)



sqlCmd.Parameters.Add("@CYTO_NUCL_POS_NOT_CENTER", Me.CheckBox37.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUCL_POS_CENTER", Me.CheckBox38.CheckState)



sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_ANI", Me.CheckBox47.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_ESO", Me.CheckBox48.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_PICNO", Me.CheckBox49.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_ISO", Me.CheckBox50.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_SINO", Me.CheckBox51.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_PIRI", Me.CheckBox52.CheckState)

sqlCmd.Parameters.Add("@CYTO_NUC_MORFI_POLI", Me.CheckBox53.CheckState)

sqlCmd.ExecuteNonQuery()

Dataset11.Clear()

connThyroid.Close()

' HERE GIVES THE PROBLEM

Me.SqlDA_Visit.Fill(Dataset11, "VISIT")

' HERE GIVES THE PROBLEM

Go_to_first() ' goes to the first of the datagrid

DataGrid1.CurrentRowIndex = 0

END OF CODE

I receive the following error

System.InvalidOperationException was unhandled
  Message="String[0]: the Size property has an invalid size of 0."


on line of the code with

Me.SqlDA_Visit.Fill(Dataset11, "VISIT")

I give some more details for the error as I get them from the copy to clipboard

  Source="System.Data"
  StackTrace:
       at System.Data.SqlClient.SqlParameter.Validate(Int32 index)
       at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters)
       at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       at First_Envirorment.Form2.Button3_Click(Object sender, EventArgs e) in C:Documents and SettingsmanolisMy DocumentsPHDImplementation!My codesFirst Envirorment_11_09_2006_with_orderForm2.vb:line 3267
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at System.Windows.Forms.Form.ShowDialog()
       at First_Envirorment.Form1.Button4_Click(Object sender, EventArgs e) in C:Documents and SettingsmanolisMy DocumentsPHDImplementation!My codesFirst Envirorment_11_09_2006_with_orderForm1.vb:line 1231
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at System.Windows.Forms.Form.ShowDialog()
       at First_Envirorment.Form3.OkButton_Click(Object sender, EventArgs e) in C:Documents and SettingsmanolisMy DocumentsPHDImplementation!My codesFirst Envirorment_11_09_2006_with_orderForm3.vb:line 144
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at First_Envirorment.Form3.Main() in C:Documents and SettingsmanolisMy DocumentsPHDImplementation!My codesFirst Envirorment_11_09_2006_with_orderForm3.vb:line 3
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

View Replies !
Save A Large String In Database
hi

is there a datatype thatcan handel a very large string ( i dont want to save it in a file and save the file in the bd ) i want to save it as it is

thanx a lot

View Replies !
How To Save Word Document In Sql Database?
 
Hi all,
I have created a word document in my application (.Net). How can I save the word document (containing tables and some HTML formats) in a database and retrieve it for later use?
Thank you in advance,

View Replies !
What Kind Of Data Can I Save In A SQL Database?
I need to save MicroStation "elements" along with other general information. Is that possible to do with SQL Server 2005?

View Replies !
Save File In SQL 2005 Database
Hello,

I am working on a ASP.NET 2.0 project with an SQL 2005 database.
I created a documents table with various columns including:
DocumentId and DocumentUrl

My documents will always be PDF's of SWF's (Flash Paper Files)

I will need to display this files in my web pages.

My question is:
Should I save the DocumentUrl in the database or should I save the file itself in the database?

And how can I save files in an SQL 2005 database?

Thanks,
Miguel

View Replies !
Stored Procedure Not Save Within Database
I am running Sql Server 2005, When I create a new stored procedure and try to save it, I'm prompted with the 'save file as dialog'. Is'nt the stored procedure suppose to be saved within the database?

View Replies !
How Can I Change The Default Save-As/Save Directory
I am new to sql sever management studio express, but a long time query analyzer user.  This is a very basic question.

 

I want to change the default directory in sql server management studio express so that when I go to save a query, it is already pointed to the correct one.  Where do I change that?

 

Thanks,

Nanci

 

 

 

View Replies !
Script, Save, Export SQL Database Diagrams
When you create database diagrams in Enterprise Manager, the detailsfor constructing those diagrams is saved into the dtproperties table.This table includes an image field which contains most of the relevantinfomation, in a binary format.SQL Enterprise manager offers no way to script out those diagrams, soI have created two Transact SQL components, one User Function and oneUser Procedure, which together provide a means to script out thecontents of the dtproperties table, including all of the binary basedimage data, into a self documenting, easy to read script. This scriptcan be stowed away safely, perhaps within your versioning software,and it can subsequently be recalled and executed to reconstruct allthe original diagrams.The script is intelligent enough not to overwrite existing diagrams,although it does allow the user to purge any existing diagrams, ifthey so choose.Once these two objects have been added to any database, you may thenbackup (script out) the current database diagrams by executing thestored procedure, like this:Exec usp_ScriptDatabaseDiagramsBy default, all database diagrams will be scripted, however, if youwant to script the diagrams individually, you can execute the sameprocedure, passing in the name of a specific diagram. For example:Exec usp_ScriptDatabaseDiagrams 'Users Alerts'The Transact SQL code for the two objects is too long to paste here,but if you are interested, I will email it to you. Just drop me a noteat: Join Bytes! (Remove bothinstances of TAKE_THIS_OUT from my email address first!!)-Clay

View Replies !
Save A Copy Of Modified Adventureworks Database
Hi
I have been working with advantureworks database and make some modifications on it.
I need to be able to have a copy of this modified adventureworks database and use it on my laptop.
How can I do this if it is possible.
What I need to do is to be able to save everything I have been working on with the adventureworks  on my desktop and be able to save on my laptop and proceed without lossing information. I want to install  trial version of sql server 2005 on my laptop and replace the advantureworks which came with it with the modified advantureworks  I have been working on.
I am travelling this week and I would like to continue what I have been working on using my laptop. I appreciate much your quick response
 
Thanks
 
 

View Replies !
How Can I Save Big File To NVARCHAR(Max) Column In The Database?
helo..
 I want to save file it size about 200MB to the database and after that

I want to get it from the database, the colmun type that i want to

save the file to it is NVARCHAR(Max).

I am using MS sql server 2005.

I was using this code to do this with Image Or Ntext column type but

it dose not working with NVARCHAR(Max) column?

 

 

Function SaveFileToDB(ByVal FileName As String, ByVal TblName As String, ByVal FldName As String, ByVal ColumnIDName As String, ByVal RowID As String) As Boolean

Try

Dim addEmp As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT @Pointer = TEXTPTR(" & FldName & ") FROM " & TblName & " WHERE " & ColumnIDName & " = '" & RowID & "'", MyConnection)

Dim trParm As SqlClient.SqlParameter = addEmp.Parameters.Add("@Pointer", SqlDbType.Binary, 16)

trParm.Direction = ParameterDirection.Output

addEmp.ExecuteNonQuery()

'''''''''''''''''''''''''''''''''''''

Dim bufferLen As Integer = 1048576

Dim appendToPhoto As SqlClient.SqlCommand = New SqlClient.SqlCommand("UPDATETEXT " & TblName & "." & FldName & " @Pointer @Offset 0 @Bytes", MyConnection)

Dim ptrParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Pointer", SqlDbType.Binary, 16)

ptrParm.Value = trParm.Value

Dim photoParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Bytes", SqlDbType.Image, bufferLen)

Dim offsetParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Offset", SqlDbType.Int)

offsetParm.Value = 0

Dim fs As IO.FileStream = New IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read)

Dim br As IO.BinaryReader = New IO.BinaryReader(fs)

Dim buffer() As Byte = br.ReadBytes(bufferLen)

Dim offset_ctr As Long = 0

Do While buffer.Length > 0

photoParm.Value = buffer

appendToPhoto.ExecuteNonQuery()

offset_ctr += bufferLen

offsetParm.Value = offset_ctr

buffer = br.ReadBytes(bufferLen)

My.Application.DoEvents()

Loop

br.Close()

fs.Close()

Return True

Catch ex As Exception

MyErrStr = ex.Message

Return False

End Try

End Function

 

 

Public Function ReadFileFromDB(ByVal MyCommandText As String, ByVal FileColumnNumber As Integer, ByVal DSTFileName As String) As Boolean

Try

Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(MyCommandText, MyConnection)

Dim stream As IO.FileStream

Dim writer As IO.BinaryWriter

Dim bufferSize As Integer = 1048576

Dim outByte(bufferSize - 1) As Byte

Dim retval As Long

Dim startIndex As Long = 0

Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()

reader.Read()

stream = New IO.FileStream(DSTFileName, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)

writer = New IO.BinaryWriter(stream)

startIndex = 0

retval = reader.GetBytes(FileColumnNumber, startIndex, outByte, 0, bufferSize)

Do While retval = bufferSize

writer.Write(outByte)

writer.Flush()

startIndex += bufferSize

retval = reader.GetBytes(FileColumnNumber, startIndex, outByte, 0, bufferSize)

My.Application.DoEvents()

Loop

writer.Write(outByte, 0, retval - 1)

writer.Flush()

writer.Close()

stream.Close()

reader.Close()

Return True

Catch ex As Exception

MyErrStr = ex.Message

Return False

End Try

End Function


 

View Replies !
Save Parameters To The Database Using Reportviewer Control.
I have reportviewer control into the aspx page and i want to save the parameters informations to the database. but i also want to stick with reportviewer parameter UI instead of my own UI.

Is that possible using ReportViewer?

Thanks in Advance

Rohit

View Replies !
!!help!! How To Save User Inputs From Checkbox List To Database??
Hi,
 
I'm new to ASP.NET 2.0. I'll like to ask how do one save user input from txtbox, radiobttnlist or checkboxlist into database?
Im implementing a suvrey form here by the way.
 -any reference webs,
-any pointers from experts?
Thank you for your time in reading this email
 
Kayln

View Replies !
Script, Save, Export SQL 2005 Database Diagrams
I've used the code from the post [Script, Save, Export SQL DatabaseDiagrams] for a while now... but recently upgraded to SQL Server 2005.I've written a new script for SQL Server 2005, which can be found athttp://www.codeproject.com/useritem...Diagram2005.asp if anyone islooking to script out database diagrams...Thanks to the original poster - Clay Beatty - for his effort.URL: [Script, Save, Export SQL Database Diagrams]http://groups.google.com.au/group/c...7802441d6466ca2

View Replies !
How Can I Open And Save A Text File To A SQL Database Using A. ASP.net W/ C# Application
Hi guys..
 
i'm having a hard time to do this one..
 
you see these are the requirements..
1. there is a text file named "Loan"
2. i must create a program using ASP.net wherein the text file can be imported in the system.
3. after importing, i must save the whole text file in a database.
 
my questions are:
 
1. what code can i do to open up a text file?
2. how can i save the text file into a database?
3. is there any way that i could import the file and view its content in my application?
4. after viewing, how can i save the text file as a text file in a database?
 
thanks to the help

View Replies !
In VB Express 2005, I Cant Save Any Record In Database Of Sql Server.
I was using the msdn tutorial regarding sql database for vb2005 express. In that tutorial, I followed the steps as listed. But the problem is that the save button in my application during run time, it does not work. Furthermore, the code for for saving a record during run time does not work as well. 

I have reinstall sql 2005 server and vb2005 express but of no use.

I have winxp with system of pentium 4.

What I should do to solve this dilemma.

Faisal. 

View Replies !
Importing An Excel File And Save Data Into A Database In My Web Account
Hi everyone, sorry if this message is not supposed to be posted here.
I'm learning asp.net , and would like to know how I can insert data from a excel file into a database on my web account. Pretty much insert/update information in the database using excel file or a access file. 
Thanks a lot in advance

View Replies !
Programatically Query Database And Save Report In An Excel Table
Hello All,

 

I am working on constructing a software layer around some features of the RDL language that would allow me to programatically generate reports.

 

I am reading the RDL specification language, and I do not understand three things:

 

1) How the DataSet element is populated by the query or more precisely how do the <Field> elements capture all the rows inside the table that is being queries?

 

 To my understanding I wilkl have to define several fields that correspond to all columns of interest in the query.

 

 But that is only for one row (?!) How do the rest of the rows get populated? Does the server recursively create new rows based on my definitions until it matches row for row all the data in the table?

 

2) Once the elements are inside a DataSet how do make use of that data to render it in a table.

 

I understand how the DataSource, DataSet, and Table work individually, yet I do not understand how to establish a flow of data between DataSet and Table.

 

3) Do I even need to use a <Table> as an RDL element in order to organize the data in an excel table?

 

 

I would appreciate any help. Thank you!

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved