|
I am new to asp.net 2.0 and i am badly confuse....Any help which can point me in a correct direction...
When we should use SqlDataSource and when we should ado.net datareader etc...What are the criteria to choose.....
Please help...
Amit
Amy
|
|
|
|
|
The SqlDataSource control allows a developer to access data stored in any relational database that supports ADO.NET. It can use the System.Data.SqlClient provider to access a SQL Server database, the System.Data.OleDb provider, the System.Data.Odbc provider, or the System.Data.OracleClient provider to access Oracle. Therefore, the SqlDataSource is certainly not only used for accessing data in a SQL Server database.
In order to use the SqlDataSource, you simply provide a value for the ConnectionString property and specify a SQL command or stored procedure. The SqlDataSource control takes care of working with the underlying ADO.NET architecture. It opens the connection, queries the data source or executes the stored procedure, returns the data, and then closes the connection for you.
Regards,
Satips.
|
|
|
|
|
Thanks...But when we should go for SQL DataSource option vs command/datareader/dataset in real world...
|
|
|
|
|
I have a very basic upload/download application. The app uses a select statement to download and a insert statement to upload. The reason I include those is because I am not sure how to get a progress report from them, ie completion percentage. I may be uploading upward of 100megs and don't want the user to just sit there waiting. I have tested a 5meg file and it takes about 3 minutes to upload and does so correctly, but the user has no idea what is going on.
How do I get progress of the SQL read/write so I can update my progress bar?
Thanks in advance!
And yes, I did post this in the C# forums, but I realized this belongs here.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Lets see the code you're using to do the INSERT. If you're using what I think you are, there is no progress reporting, and hence no progressbar possible.
|
|
|
|
|
szSQLCommand1 = "INSERT INTO Files(Name, Size) VALUES(@Name, @Size)";<br />
szSQLCommand2 = "INSERT INTO FileData(Data) VALUES(@Data)";
I am not stuck to this approach though, I am looking for the way to do it...
I have SQL Server 2005 Full Edition up on a remote server that I have full access to if that comes into play.
I don't know too much about SQL or its different statements, procedures, ect. But a point in the right direction of what I need to learn and I can do that.
Thanks for the help, and the quick reply.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
This isn't the complete code to do the upload.
|
|
|
|
|
string szSQLCommand1;<br />
string szSQLCommand2;<br />
Int32 intFileSize;<br />
byte[] rawData;<br />
FileStream fsRead;<br />
<br />
try<br />
{<br />
fsRead = new FileStream(lblPath.Text, FileMode.Open, FileAccess.Read);<br />
intFileSize = Convert.ToInt32(fsRead.Length);<br />
<br />
rawData = new byte[intFileSize];<br />
fsRead.Read(rawData, 0, intFileSize);<br />
fsRead.Close();<br />
<br />
mySQLConnection.Open();<br />
<br />
szSQLCommand1 = "INSERT INTO Files(Name, Size) VALUES(@Name, @Size)";<br />
szSQLCommand2 = "INSERT INTO FileData(Data) VALUES(@Data)";<br />
<br />
cmd.Connection = mySQLConnection;<br />
cmd.CommandText = szSQLCommand1;<br />
cmd.Parameters.AddWithValue("@Name", txtName.Text);<br />
cmd.Parameters.AddWithValue("@Size", intFileSize);<br />
<br />
cmd2.Connection = mySQLConnection;<br />
cmd2.CommandText = szSQLCommand2;<br />
cmd2.Parameters.AddWithValue("@Data", rawData);<br />
<br />
cmd.ExecuteNonQuery();<br />
cmd2.ExecuteNonQuery();<br />
<br />
MessageBox.Show("File Inserted into database successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);<br />
<br />
mySQLConnection.Close();
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
There is no way for this code to give you a progress update. This code will block on both ExecuteNonQuery statements. Neither can give you any kind of progress data, not the UI thread time to show it.
|
|
|
|
|
Hey,
I am wondering if it is possible, and what would be the best way?
I'm working on a batch process to take care of building our applications, push/pull from source control and update the databases. As far as updating the DB, there will be a few scripts that need to run and I would like to call them from the same batch process that updates our executables (I really don't want to run a batch file AND set up a SQL job).
The goal is to have a single (1) job which will take care of everything to reduce the chance of error.
Can someone point me in the right direction?
Thanks,
Pualee
|
|
|
|
|
For oracle you can use sqlplus calls, for Sql Server you can use iSql.
Mike Lasseter
|
|
|
|
|
Thanks for the jumping off point, I'm looking into this, more specifically oSQL now
|
|
|
|
|
Hey guys,
I need to know how to add a table to a database in SQL Server 2000.
With C# code its possible to change tables, i.e to update or delete rows or whatever, but how can I create a new table? Is this possible? do you have any ideas?
thanks in advance
|
|
|
|
|
Leia2011 wrote: how can I create a new table?
You can put pretty much any SQL command you like through an SqlCommand object. If you don't expect a result set back use ExecuteNonQuery()
Leia2011 wrote: Is this possible?
yes.
Leia2011 wrote: do you have any ideas?
See above.
|
|
|
|
|
Hi
I have created one master job in sqlserver 2000 which run several jobs in different steps.
But it excutes all jobs at a time. I want that job run one by one.
I have set property like "Go TO Next in one finish successfully" but it didnt work in this case.
If i run several store procedures in one job then they run one by one as i need but when i put jobs inside job then they run simultaneously.
I also tried by putting each job in seprate store procedure and kept that store procedures in each steps but it also didnt work and run simultaneously.
I can not understand how to do it.
Could anybody give me the solution?
Thanks in advance.
|
|
|
|
|
Jobs are meant to be independent of each other. How about using moving your code into a DTS package - with "success" constraints linking each task? The master job would then just need to execute that one DTS package.
|
|
|
|
|
SOftware I'm using
Visual Studio 2005
SQL Express 2005
SQL Server Business Intelligence Studio
My Problem:
I created two reports and using the same parameter for each report. I add report2 to report 1 as a subreport and whenever I preview report1, report2 never shows as the subreport. I doubled, tripled check that they are using the same parameter but I read in another article that you need to pass a report parameter and not a query parameter? What's the difference? Help would be greatly appreciated.
Thanks
Jon
|
|
|
|
|
Hi,
I need to find all the indexes in a table from access database.
please help me .
thank you.
|
|
|
|
|
You could try the ADOX or DAO.
|
|
|
|
|
I want to insert a binary file, say "tt.bin", into a field (image type) of SQL database, I wrote a program as follows
C++, VS2003, ADO, input file: tt.bin,database: moldb,
Create table moltbl (id INT, mol IMAGE);
But I didn't get nothing in the output file: new.bin
where am I wrong, please? thanks very much!
// BLOB.cpp
#import "c:/Program Files/Common Files/System/ADO/msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include
#include
using namespace std;
int main()
{
::CoInitialize(NULL);
_RecordsetPtr m_pRecordset("ADODB.Recordset");
_ConnectionPtr m_pConnection("ADODB.Connection");
_bstr_t bstrSQL("select * from moltbl");
ifstream moldata;
moldata.open("tt.bin", ios::in|ios::binary);
ofstream newdata;
newdata.open("new.bin", ios::out|ios::binary);
char buffer[10240];
char *pBuf = buffer;
long nFileLen = 0;
if (!moldata.fail() && !moldata.eof())
moldata.read(buffer,10240);
nFileLen = moldata.gcount();
VARIANT varBLOB;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
int index = 0;
_bstr_t strConnect = "Provider=SQLOLEDB; Server=ELSE-HP;"
"Database=moldb; uid=sa; pwd=sa";
m_pConnection->Open(strConnect, "", "", adModeUnknown);
if(m_pConnection == NULL)
cerr<<"Load data ERROR!\n";
HRESULT hr = m_pRecordset->Open("SELECT * FROM moltbl",
_variant_t((IDispatch *)m_pConnection,true),
adOpenDynamic,
adLockPessimistic,adCmdText);
m_pRecordset->AddNew();
m_pRecordset->PutCollect("id",_variant_t(index++));
if(pBuf)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < (long)nFileLen; i++)
SafeArrayPutElement (psa, &i, pBuf++);
varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;
m_pRecordset->GetFields()->GetItem("mol")->AppendChunk(varBLOB);
}
m_pRecordset->Update();
long lDataSize =_pRecordset->GetFields()->GetItem("mol")->ActualSize;
ifstream newfile;
newfile.open("new.bin", ios::out| ios::binary);
if(lDataSize > 0)
{
_variant_t varBLOB;
varBLOB = m_pRecordset->GetFields()->GetItem("mol")->GetChunk(lDataSize);
if(varBLOB.vt == (VT_ARRAY | VT_UI1))
{
SafeArrayAccessData(varBLOB.parray,(void **)&pBuf);
newdata.write(pBuf, lDataSize);
SafeArrayUnaccessData (varBLOB.parray);
}
}
moldata.close();
newdata.close();
return 0;
}
Hi, there. Need your help!
Hi, there.
|
|
|
|
|
Hey what error it shows?
Regards,
Satips.
|
|
|
|
|
Thanks for your attention!
No error, everything seems OK, but I couldn't get the right result,
I insert the binary file into the database, and then I retrieve and output it into a binary file, but I got nothing in the new file?
what's the matter? thanks a lot!
Hi, there.
|
|
|
|
|
Sorry, but it's already 9:00 PM in my time-zone, I have to leave now, I'll try to fix my program tonight, but if you could give me any suggestions, that'll be much appreciated.
PS. I'm just a beginning learner, so please explain in details. Thanks. See you.
Hi, there.
|
|
|
|
|
I've stepped into it, and find something seems wrong here:
if(pBuf)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < nFileLen; i++)
SafeArrayPutElement (psa, &i, pBuf++);
varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;
m_pRecordset->GetFields()->GetItem("mol")->AppendChunk(varBLOB);
}
because when i did as follow:
m_pRecordset->Update();
long lDataSize = m_pRecordset->GetFields()->GetItem("mol")->ActualSize;
I find that the value of lDataSize is alwayse -1
do you know the reason, please?
thanks a lot
regards.
Li
Hi, there.
|
|
|
|
|
hi all
i am having a stored procedure in my database which will take 2 parameters and return a resultset which i want to display in a crystal report.when i am executing the store proc. alone with the paramaters in the query analyser of sql server 2000,it is taking around 2.5 min.but when i pass the parameters from a vb.net page page,it z showing an error:{"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."}
please help me out to solve this problm..
thanks in advance
i am Pradip Kishore
|
|
|
|
|