|
You could convert the document into a string and then store it in the database. May not be the most compact way of storing it, however.
|
|
|
|
|
XGaMeS wrote:
I want to store xml file in a ntext datatype in sql server 2000
Erm... what is XML, if it's not text ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
And any clues on how to conevert it and pass it as a parameters ?
I am...
|
|
|
|
|
Okay, here's a senario that may help. Create your stored procedure to handle actually commiting the data to the database
CREATE PROCEDURE InsertXMLData
{
@XMLData ntext
}
AS
INSERT INTO MyDemoTable (XMLData) VALUES (@XMLData);
GO
To use this procedure do the following:
<code>
Private Sub InsertXML(ByVal XMLData as XMLDocument)
' create a sqlconnection
Dim SQLCon as New SQLConnection("server=...")
' create a sql command
Dim SQLCon as New SQLCommand("InsertXMLData", SQLCon)
' Set the command type and add parameters
SQLCon.CommandType = CommandType.StoredProcedure
SQLCon.Parameters.Add("@XMLData", XMLData.OuterXML.ToString)
' Variable to store records added.
Dim RecordsAdded as Integer
' Execute a non-query
Try
SQLCon.Open
RecordsAdded = SQLCmd.ExecuteNonQuery
Catch sqlex as SQLException
RecordsAdded = -1
Catch ex as Exception
RecordsAdded = -1
Finally
SQLCon.Close
End Try
End Sub
</code>
You will want to make sure to research more about the System.Data.SQLClient namespace for more information on using parameters with SQL Commands.
Hope this is useful!
|
|
|
|
|
There's nothing to convert. You just open the file and read it into a string.
Dim sr As StreamReader = New StreamReader("C:\myPath\TestFile.xml")
Dim content As String
content = sr.ReadToEnd()
sr.Close()
Then you just pass the string to your SQLCommand as you would any other SQLParameter.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
*sigh* Thank you.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I have 2 datagrid one data grid contain data and
the other one is empty.How can the selected row
insert in to the second data grid by one by one.
using with enter key or button press
|
|
|
|
|
When enter key or button is pressed, add new row to dataset:
Dim drNew As DataRow
drNew = DATASET.Tables(0).NewRow 'Create the new row
drNew.Item("FIRST") = txtFirst.Text
drNew.Item("LAST") = txtLast.Text
drNew.Item("PHONE") = txtHome.Text
DATASET.Tables(0).Rows.Add(drNew) 'Adds new row to dataset Hope this helps
Beginner in ASP.Net and VB.Net
|
|
|
|
|
Does anyone know where I could find info on the changes in the treeview control between VB6 and VB.NET?
I am trying to convert some code over and it doesn't seem that the new TreeNodes (in .NET) have a unique key (or equivalent). I don't really want have to scan the entire tree (3k item, possibly) to try to find the match.
Any ideas?
Thanks
Scott
modified 12-Jan-22 21:01pm.
|
|
|
|
|
|
Hi, I was wondering if anyone out there might have a solution to displaying multiple data fields from a dataset, in columnar form, within a listbox.
eg. FirstName LastName Address
Thank you
|
|
|
|
|
|
Hi, thanks for your reply. This code does sort the information into columns, but not horizontally. I am looking to display multiple columns, in both a listbox and combobox, populated from a database using a dataset.
eg.
FirstName LastName Phone#
Jeff Smith (555)555-5555
John Doe (555)123-4567
etc
I have tried to use the listview, but listview does not have a datasource or selected indexes, selected values etc.
Any further input would be much appreciated. Thank you.
|
|
|
|
|
Hi, thanks for your reply. This code does sort the information into columns, but not horizontally. I am looking to display multiple columns, in both a listbox and combobox, populated from a database using a dataset.
eg.
FirstName LastName Phone#
Jeff Smith (555)555-5555
John Doe (555)123-4567
etc
I have tried to use the listview, but listview does not have a datasource or selected indexes, selected values etc.
Any further input would be much appreciated. Thank you.
|
|
|
|
|
Hi, I'm new to vb.net and was wondering if there is any way to code a function in a parent class or something to handle the gotfocus and leave events for all of the controls in my form. I want to do this to reduce the code in my application. Thank you.
|
|
|
|
|
You can add multiple handlers to a single function. For example, if you have three text boxes on your form:
Private Sub MyCustomHandler(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged, _
TextBox2.TextChanged, TextBox3.TextChanged
MsgBox("I changed!")
End Sub
|
|
|
|
|
Hi, thanks for your reply. I have been able to create a customer textbox control to handle the events. I added this custom control to my toolbox and it will handle the evert everytime I insert an instance of the object into the forms.Thank you for your help.
|
|
|
|
|
Hi,
im new to VB. I like to interact with an registered activex control. F2 shows the analogous event ScanReady(occurs when datafile from scanner is at the clippboard)
The tree is like:
Event ScanReady(pDobj As IDataObject)
|_
Class IDataObject:
Sub QueryGetData(pformatetc As tagFORMATETC)
|_
Type tagFORMATETC
How to implement a message shown in my form when data is avaible??
My idea is like this:
_________________________________________
Private Sub ScanReady()
Dim pDobj As IDataObject
pDobj.QueryGetData (pformatec)
Label1.Caption = "Scandata avaible"
End Sub
_________________________________________
Private Sub QueryGetData()
Dim pformatec As tagFORMATETC
End Sub
_________________________________________
Can somebody help me?
happy coding,
-mark
|
|
|
|
|
I have to print receipts receipts from my application. I print on continuous form page and the user for example selects 1000 receipts and send them to printing. What my problem is that the receipt pages have sizes other than standart A4 and in my PrintDocuments constructor i do sth like this:
Me.DefaultPageSettings.PaperSize = New PaperSize("Fatura", 200 * 100 / OneInchInMillimeters, 200 * 100 / OneInchInMillimeters)
In print preview I see the right document size but when i send the pages to printing the printer (currently OKI Microline 3320) rolls each page as size of A4, not as my receipt documents height.
Do I have to do something on printer?
|
|
|
|
|
hi,
The reson is because of few factors.
1) Font Size of your content.
2) No of lines per page etc.
What you can do is, if you want to print without any breaking then please see the below mwntioned code. This will deside howmany lines need to print based on Font Size
private void menuItem6_Click(object sender, System.EventArgs e)
{
try
{
PrintDia=new PrintDialog();
PrintDia.Document=printDocument1;
string content=this.Editor.Text;
StrReader=new StringReader(content);
if(PrintDia.ShowDialog()==DialogResult.OK)
{
this.printDocument1.Print();
}
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
float Lines_Per_Page = 0;
float Y_Position = 0;
int Count = 0;
float Left_Margin = e.MarginBounds.Left;
float Top_Margin = e.MarginBounds.Top;
string Line = null;
Font fnt = Editor.Font;
SolidBrush Solid = new SolidBrush(Color.Black);
Lines_Per_Page=e.MarginBounds.Height/Font.GetHeight(e.Graphics);
while(Count < Lines_Per_Page && ((Line=StrReader.ReadLine())!=null ))
{
// calculate the next line position based on
// the height of the font according to the printing device
Y_Position =Top_Margin + (Count * fnt.GetHeight(e.Graphics));
// draw the next line in the rich edit control
e.Graphics.DrawString(Line ,fnt ,Solid ,Left_Margin ,Y_Position ,new StringFormat());
Count++;
}
if(Line !=null)
e.HasMorePages=true;
else
e.HasMorePages=false;
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
try
{
string Content=Editor.Text;
StrReader = new StringReader(Content);
PrintPreviewDialog Print_Preview=new PrintPreviewDialog();
Print_Preview.Document=printDocument1;
Print_Preview.ShowDialog();
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
This gave me an idea. What my problem is that my users print receipts at the end of the month collectively and even a marginal error in determining the height of the page will make a big difference say on 900th page.
I thought I can make the width of the page very large and print a 1000 inch height as a page. But as I said a page is a4 and when i draw by GDI+ say on y=30 cm (out of a4 height) it simply does not print it.
Now it seems to me that I can modify your code to satisfy my needs. The papersize remains A4 and I print multiple A4 pages but adjust coordinates so that the code regularly prints on A4. I will now measure the height of my receipt and I hope that it is 1/2 or 1/3 of a A4
But anyway, why changing paper size is problem? why do we need to write a lot of code instead of just defining a custom paper size? I am afraid MS engineers think that only companies with laser or ink jet printers will run their code or maybe youngsters which will print their term projects or favorite lyrics
|
|
|
|
|
hi
Levent Özkan Wrote :
This gave me an idea.
This is the thing i expect from my effort after submitting the answer which is known to me.
Levent Özkan Wrote :
Now it seems to me that I can modify your code to satisfy my needs.
This is the thing that we want from your side. Because now a days i seen lot of youngsters want spoon feeding. And it is not possible to sit and figurout their entire needs (I am working for some other company).
Good.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi,
Thanks for the code again, be sure that this effort will generate an tutorial on continuous form paper. I also learned another way to print text-only reports. I will use this if any other methods fail.
There is an article from Ms which tells how to send raw data to the printer by bypassing GDI+. By using this you can send raw text to printer. The good side of this approach is that the character width is fixed. We can set printer to narrow mode (136 columns) by sending Chr(15) & Chr(15) as first bytes. Then I printed a reference page on which there are column and row positions are printed and put receipt on it to fing receipt content coordinates. Somebody told me that all receipt papers, independent from its type, has a height which is a integer multiple of the height of one row when you print raw strings. The only problem with this path is that you must write some custom code in win98
|
|
|
|
|
Does your printer (and driver) support custom paper sizes? (Many do not)
Use the GetDeviceCaps API call (or there may be a .NET class equivalent) to find out.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I realized that setting the PaperSize in program is not enough. My host printer is OKI Microline 3320 and I solved my problem by setting Page Length to 6 inch. Then giving value of (W:780, H:600) which is the receipt size of my customers to PaperSize, I saw that now the tractor of the printer rolls the page correctly.
|
|
|
|