|
In CSqlStatement::Bind(int, CString) error unicode here correct code:
_sqlite_bind_text(..., v, v.GetLength() * sizeof(WCHAR),..)
|
|
|
|
|
Hi
I need your help in,
I am working on a project, MYSQL and PHP based, with WAMP SERVER
I have a field storytext, (data collected in URDU) detail are:
<b>Field Type Collation Null Default
storytext text utf8_unicode_ci Yes NULL</b>
Retrieving URDU Data from MY SQL 5.5.8 running on wamp server with PHP is OK,
And the soft ware is only for Internal use not web base!
------------------------------------------------------------------------------------------
<b>HERE IS THE PROBLEM:</b>
One section of it is designed on Visual Studio.NET 2010 in which
I have a datagrid, on clicking any row I got the TEXT in details on text box,
which show <b>URDU TEXT</b>, from data base here is the problem with <b>TEXT BOX and DATAGRID.</b>
I got this..........
<b>DESP. ITEM
پروگرام رانا مب
شر ايٹ پرائم ٹائم ميں
گ٠تگو کرتے Û ÙˆØ¦Û’ وزير٠اعظم Ú©Û’
وکيل Ú†ÙˆÛ Ø¯Ø±ÙŠ اعتزاز اØسن
کا Ú©Û Ù†Ø§ تھا Ú©Û ØµØ¯Ø± Ú©Û’ Ø¹Û Ø¯Û’
Ú©Ùˆ استشني Øاصل Û Û’
وزير٠اعظم Ø</b>
-------------------------------------------------------------------------------------------------------
I also use in visual studio
<b>cnString = "datasource=localhost;username=root;password=;database=spidernews;charset=utf8;"</b>
How can I solve this problem,
can you help me out !
<b>URDU NOT SHOWING, </b>
<pre lang="vb">Here is Whole CODE of Visual Studio, I am using:
------------------------------------------------------------------------------------------------------------------------</pre>
<pre lang="text">
Imports MySql.Data.MySqlClient
Public Class Form1
Dim conn As Common.DbConnection
Dim da As Common.DbDataAdapter
Dim ds As DataSet = New DataSet
Dim cnString As String
Dim sqlQRY As String
'Dim dt As DataTable
'Dim strBuilder As Char
'''' SCROLLONG TEXT START
Dim scrollingText As String = "Spider NEWS "
Dim txtStr(scrollingText.Length - 1) As String
Dim txtPos As Integer = -1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'strBuilder.ToString ("tblnews" & char(34))
cnString = "datasource=localhost;username=root;password=;database=spidernews;charset=utf8;"
sqlQRY = "SET NAMES UTF8; SET CHARACTER SET UTF8;Select slugid,slug,storytext,storyduration,segmentdescription,prioritydescription,mosstatus from tblnews"
'sqlQRY = "SET NAMES UTF8; SET CHARACTER SET latin1;Select slugid,slug,storytext,storyduration,segmentdescription,prioritydescription,mosstatus from tblnews"
conn = New MySqlConnection(cnString)
Try
conn.Open()
da = New MySqlDataAdapter(sqlQRY, conn)
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
da.Fill(ds, "tblnews")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "tblnews"
'''''
Catch ex As Common.DbException
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
'''' SCROLLONG TEXT START
For idx As Integer = 0 To UBound(txtStr)
Dim workedString As String = ""
workedString = scrollingText.Substring(idx) & " " & scrollingText.Substring(0, idx)
txtStr(idx) = workedString
Next
Timer1.Interval = 5000
Timer1.Enabled = True
Timer1.Start()
'''' SCROLLONG TEXT END
Label2.Text = System.DateTime.Now
End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
da.Update(ds, "" + TextBox1.Text + "")
MsgBox("Data sent", MsgBoxStyle.OkOnly, "Sucess")
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim i, j As Integer
i = DataGridView1.CurrentRow.Index
RichTextBox1.Text = DataGridView1.Item(2, i).Value
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim i, j As Integer
i = DataGridView1.CurrentRow.Index
'''' SCROLLONG TEXT START
txtPos += 1
Dim timerStr As String
timerStr = txtStr(txtPos)
RichTextBox1.Text = DataGridView1.Item(2, i).Value
Label1.Text = timerStr
If txtPos = UBound(txtStr) Then txtPos = -1
'''' SCROLLONG TEXT START
End Sub
End Class
</pre>
|
|
|
|
|
|
I am trying to insert a Blob into a sqlite database using your code.
I don't understand how the 'Bind' functions in CSQLStatement class are called nor how this class fits with the 'CDbSqlite' class.
Do you have any example code espially that deals with Blobs ?
Any help is much appreciated.
Regards,
Alan Buchanan
|
|
|
|
|
when run the w32Test in "Download demo project w/source" that you provided in VS2005,detected Memory leaks.
At the end of function CTestDlg::OnPbReview(),I added:
if(stmt)
{
delete[] stmt;
}
Then no memory leaks.
modified on Friday, December 3, 2010 3:44 AM
|
|
|
|
|
Excellent work!
but, I find a bug when calling SelectStatement in VS2005, it seems that LPCTSTR is not equal to CString.
in function:
int
CDbSQLite::SelectCallback(void *p_data, int num_fields, char **p_fields, char** /*p_col_names*/)
{
ResultTable* res = reinterpret_cast<ResultTable*>(p_data);
ResultRecord record;
for ( int i=0; i < num_fields; i++ )
{
CString szField = CString(p_fields[i]);
record.m_fields.push_back(szField); // this row works abnormal in vs2005
}
res->m_records.push_back(record);
return 0;
}
you can use:
class ResultRecord
{
public:
std::vector<CString> m_fields;
};
instead of
class ResultRecord
{
public:
std::vector<LPCTSTR> m_fields;
};
|
|
|
|
|
The code worked well in my projects. Thanks!
|
|
|
|
|
Hi,
I'm very glad to see that you've done this wrapper, i've been looking all over for such a thing.
Now, i'm trying to run this on Windows Mobile 5 with VS 2005. I followed all the steps you said, i converted all the projects and made all the changes for the newer version of WM and VS. It builds ok, but when i try to deploy it on the emulator, i get this error: Unable to start program: '%CSIDL_PROGRAM_FILES%\wceTest.exe'
I try to run on the device itself, by copying the wceTest.exe on the device. I still get the error.
Do i have to register any dll or something to make it work?
Could you help me please with this, i really need this wrapper, but i dunno how to make it work.
Thanks a lot!
|
|
|
|
|
Keep in mind that I am just speculating on your problem. It seems to me that you may not have your emulator configured with a full ActiveSync partnership. This article at O'Reilly might help. Please let us all know if it does.
|
|
|
|
|
One other thing occurred to me as I re-read your post. I'm assuming you are using the wrapper as a DLL. Did you sync both the test application and DLL to the device/emulator?
|
|
|
|
|
I guess that the problem was that the executable was not able to find the DLL's needed.
I tried to copy on the device in the same directory wceTest.exe and wceSQLite3.dll and still didn't work. And then i took a look on wceTest project properties, and the Deployment -> Additional Files box was left blank. I added there some DLL's that somehow my Visual Studio missed to put: msvcr80.dll, atl80.dll, msvcr80d.dll, MFC80UD.dll, and then the wceSQLite3.dll, and i checked "yes" on Register Output, and now it works.
I hope this will help ppl having the same problem.
Thanks very much for the quick response and good luck with your coding
|
|
|
|
|
hi everyone
Can I uses SQLite to connect to MS SQL Server and read and write some data to it ?
do you have any idea ?
please help!!!
|
|
|
|
|
You cannot.
Actually, the question misses the point of using SQLite. Furthermore, there is not enough information in your post that is sufficient to offer you suggestion(s) about how you might proceed. For example, development language, etc. I recommend you search code project to see if you can find anything that will help you with SQL Server. For example, there is at least one ADO wrapper on this site that I have used in the past on a C++ project. If you use any of the .NET family of languages, then you already have everything you need.
|
|
|
|
|
Tanks,
I have find som information about ODBC is not supported on CE and OLEDB driver is not available form Win CE device.
Can I uses ADO wrapper to direct access to SQL server in my network.
I uses C++ language, but I can not finde some examples in C++.
Thank you very much !
|
|
|
|
|
My previous response included a hyperlink that would have displayed numerous ADO projects for you to consider. Several of them written in C++, .NET, etc. Just click on the highlighted phrase "code project" because it is actually a link to a page of search results.
Finding ADO examples should not be difficult. It is definitely a skill I encourage you to develop because it will be fundamental to accomplishing your task. For what it is worth, I ran a simple keyword search here on code project using "ADO wrapper" and came up with this link.
Here's wishing you good luck and Happy Fishing!!!
modified on Monday, May 4, 2009 6:53 AM
|
|
|
|
|
Using source from sqlite 3.4.0 causes DbSQLite to fail in compilation with the following message.
error C2065: 'CHAR_BIT' : undeclared identifier
|
|
|
|
|
You have reported a common problem that occurs when the open source package for SQLite is updated while the source code for this article is not (See Warnings and Disclaimers) maintained.
Since this is obviously a simple source code version problem, please advise everyone how you solved it so it would compile. In that way, you can help others who follow in your footsteps.
|
|
|
|
|
hello.
i use VC++.NET 2005 and, i don't know, how add and use this dll in my program. please help me. tell me clearly.
|
|
|
|
|
While I have not read it myself, I understand that this book does a fair job teaching the application framework fundamentals you should know before you can accomplish your task. If you believe you already know the fundamentals, then Microsoft has a knowledge base article titled How to add references to a managed Visual C++ project that should serve as a refresher so you can solve your problem.
Here's wishing you good luck and Happy Fishing!!!
|
|
|
|
|
I can't read more than 2KB from text column with this wrapper. Other wrapper for .net works good on same database.
|
|
|
|
|
I cannot be certain of your comparison since I do not have a clue as to what you mean by your statement that the "Other wrapper for .net works good on same database." Your statement confuses me because the wrapper described in this article is based upon MFC and not Microsoft's managed code. My confusion is probably based upon my belief that it is important to distinguish the difference between MFC/C++ and managed code. In other words, code is not .NET just because it compiles using Visual Studio.NET. Is the ".NET" version to which you refer really managed code?
In any case, more specific information would be useful before I can offer any meaningful insight. For example, what version of SQLite3 are you using with the ".NET" version that you consider to be working “good” [well] in your tests? Is the ".NET" version you are using access SQLite3 dynamically through a DLL? If you are using a DLL, does your ".NET" version use the same DLL as the one you are using to test this wrapper? Are you running your test on a desktop operating system or one of the WinCE/PPC/Mobile operating systems? Is your ".NET" version running on WinCE or Pocket PC?
Meanwhile, I can only speculate about the problem you are experiencing. Since the wrapper described by DbSqlite.h only uses the MFC CString class along with LPCTSTR style pointers, it is unlikely that the 2KB limit you describe is directly related to the wrapper. If I needed to resolve this problem for my work, I would consider whether or not the problem I am experiencing resides with the version of SQLite3 being used for my tests.
-- modified at 8:47 Tuesday 30th January, 2007
|
|
|
|
|
Here is the example of database: http://www.volny.cz/hampl/pomocne/data_pokus.db3.
I can read only 2KB from column long_desc if I use this wrapper on pocketpc. I tried to compile dll from actual sqlite source, but with same issue. If I use other application for .net compact framework (version 2.0 SP1) with this database, it works good. This .net application uses own sqlite library. It's only test that this database is good and contains more than 2KB in this column and it's possible to read this data. I use WM5, VS 2005. I compile for WM5 platform.
|
|
|
|
|
LPTSTR pom = (LPTSTR)_sqlite3_column_text(m_stmt, pos_zero_indexed);
m_szText = pom;
works better than
m_szText.Format(_T("%s"), _sqlite3_column_text(m_stmt, pos_zero_indexed));
I get whole string now, not only 2KB of text. Is it feature or error of CString::Format?
|
|
|
|
|
Given that this solved your problem, I wonder if you have any characters embedded in the text that CString::Format would interpret as the end-of-string? Of course, this is only speculation based upon the fact that your use of pointers (LPTSTR) seemed to have solved the problem. This is even more confusing since I assume that _sqlite3_column_text would terminate the string at the first NULL.
Could you double check that the table I downloaded is the correct one from which to review the problem?
|
|
|
|
|
I downloaded your file and found your column long_desc in table cache_wpt. I used the SQLite Database Browser Version 1.2.1 found here to review your database. Unfortunately, I only see the test "
|
|
|
|
|